X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fcommon%2Ftype_traits.h;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fcommon%2Ftype_traits.h;h=eb7a1921c00b6eeac605927682ba4178059f3b48;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/type_traits.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/type_traits.h new file mode 100644 index 0000000..eb7a192 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/type_traits.h @@ -0,0 +1,124 @@ +// Copyright 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include + +namespace anbox { +namespace common { + +namespace details { + +// a simple helper class for SFINAE below. +template +struct dummy { + using type = X; +}; + +} // namespaces details + +// add some convenience shortcuts for an overly complex std::enable_if syntax + +// Use 'enable_if' instead of +// 'typename std::enable_if::type' +template +using enable_if = typename std::enable_if::type; + +// Use 'enable_if_c' instead of +// 'typename std::enable_if::type' +template +using enable_if_c = typename std::enable_if::type; + +// Use 'enable_if_convertible' instead of +// 'typename std::enable_if::value, Type>::type' +template +using enable_if_convertible = enable_if>; + +// ----------------------------------------------------------------------------- +// A predicate for checking if some object is callable with a specific +// signature. Examples: +// +// is_callable_as::value == false. +// is_callable_as::value == false. +// is_callable_as::value == true +// +template +struct is_callable_as : std::false_type {}; + +// This specialization is SFINAE-d out if template arguments can't be combined +// into a call expression F(), or if the result of that call is not |R| +template +struct is_callable_as< + F, R(), typename std::enable_if()())>::type, + R>::value>::type> : std::true_type {}; + +// One more specialization, for non empty argument list +template +struct is_callable_as()( + std::declval()...))>::type, + R>::value>::type> : std::true_type {}; +// ----------------------------------------------------------------------------- +// Check if a type |T| is any instantiation of a template |U|. Examples: +// +// is_template_instantiation_of::value == false +// is_template_instantiation_of< +// std::list>, std::vector>::value == false +// is_template_instantiation_of, std::vector>::value == true +// is_template_instantiation_of< +// std::vector>, std::vector>::value == true +// +template class U> +struct is_template_instantiation_of : std::false_type {}; + +template