gcc/libstdc++-v3/include/experimental/type_traits

311 lines
11 KiB
Plaintext
Raw Normal View History

// Variable Templates For Type Traits -*- C++ -*-
// Copyright (C) 2014-2017 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file experimental/type_traits
* This is a TS C++ Library header.
*/
//
// N3932 Variable Templates For Type Traits (Revision 1)
//
#ifndef _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS
#define _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS 1
#pragma GCC system_header
#if __cplusplus <= 201103L
# include <bits/c++14_warning.h>
#else
#include <type_traits>
Fix libstdc++ versioned namespace build PR libstdc++/68323 PR libstdc++/77794 * config/abi/pre/gnu-versioned-namespace.ver: Add exports for __cxa_thread_atexit and __gnu_cxx::__freeres. * include/Makefile.am: Add <experimental/bits/lfts_config.h> * include/Makefile.in: Regenerate. * include.bits/basic_string.h: Fix nesting of versioned namespaces. * include/bits/c++config: Declare versioned namespaces for literals. * include/bits/regex.h (basic_regex, match_results): Add workarounds for PR c++/59256. * include/bits/uniform_int_dist.h: Fix nesting of versioned namespace. * include/std/chrono: Likewise. * include/std/complex: Likewise. * include/std/string_view: Likewise. * include/std/variant: Likewise. Add workaround for PR c++/59256. * include/experimental/bits/fs_fwd.h: Declare versioned namespace. * include/experimental/bits/lfts_config.h: Declare versioned namespaces. * include/experimental/algorithm: Include <experimental/bits/lfts_config.h>. * include/experimental/any: Likewise. * include/experimental/bits/erase_if.h: Likewise. * include/experimental/chrono: Likewise. * include/experimental/functional: Likewise. * include/experimental/memory_resource: Likewise. * include/experimental/optional: Likewise. * include/experimental/propagate_const: Likewise. * include/experimental/random: Likewise. * include/experimental/ratio: Likewise. * include/experimental/system_error: Likewise. * include/experimental/tuple: Likewise. * include/experimental/type_traits: Likewise. * include/experimental/utility: Likewise. * include/experimental/string_view: Likewise. Fix nesting of versioned namespaces. * include/experimental/bits/string_view.tcc: Reopen inline namespace for non-inline function definitions. * testsuite/17_intro/using_namespace_std_exp_neg.cc: New test. * testsuite/20_util/duration/literals/range.cc: Adjust dg-error line. * testsuite/experimental/any/misc/any_cast_neg.cc: Likewise. * testsuite/experimental/propagate_const/assignment/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise. * testsuite/experimental/propagate_const/requirements2.cc: Likewise. * testsuite/experimental/propagate_const/requirements3.cc: Likewise. * testsuite/experimental/propagate_const/requirements4.cc: Likewise. * testsuite/experimental/propagate_const/requirements5.cc: Likewise. * testsuite/ext/profile/mutex_extensions_neg.cc: Likewise. From-SVN: r240714
2016-10-03 16:35:28 +02:00
#include <experimental/bits/lfts_config.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace experimental
{
inline namespace fundamentals_v1
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_experimental_type_trait_variable_templates 201402
// See C++14 §20.10.4.1, primary type categories
template <typename _Tp>
constexpr bool is_void_v = is_void<_Tp>::value;
template <typename _Tp>
constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
template <typename _Tp>
constexpr bool is_integral_v = is_integral<_Tp>::value;
template <typename _Tp>
constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
template <typename _Tp>
constexpr bool is_array_v = is_array<_Tp>::value;
template <typename _Tp>
constexpr bool is_pointer_v = is_pointer<_Tp>::value;
template <typename _Tp>
constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
template <typename _Tp>
constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
template <typename _Tp>
constexpr bool is_member_object_pointer_v =
is_member_object_pointer<_Tp>::value;
template <typename _Tp>
constexpr bool is_member_function_pointer_v =
is_member_function_pointer<_Tp>::value;
template <typename _Tp>
constexpr bool is_enum_v = is_enum<_Tp>::value;
template <typename _Tp>
constexpr bool is_union_v = is_union<_Tp>::value;
template <typename _Tp>
constexpr bool is_class_v = is_class<_Tp>::value;
template <typename _Tp>
constexpr bool is_function_v = is_function<_Tp>::value;
// See C++14 §20.10.4.2, composite type categories
template <typename _Tp>
constexpr bool is_reference_v = is_reference<_Tp>::value;
template <typename _Tp>
constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
template <typename _Tp>
constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
template <typename _Tp>
constexpr bool is_object_v = is_object<_Tp>::value;
template <typename _Tp>
constexpr bool is_scalar_v = is_scalar<_Tp>::value;
template <typename _Tp>
constexpr bool is_compound_v = is_compound<_Tp>::value;
template <typename _Tp>
constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
// See C++14 §20.10.4.3, type properties
template <typename _Tp>
constexpr bool is_const_v = is_const<_Tp>::value;
template <typename _Tp>
constexpr bool is_volatile_v = is_volatile<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivial_v = is_trivial<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
template <typename _Tp>
constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
template <typename _Tp>
constexpr bool is_pod_v = is_pod<_Tp>::value;
template <typename _Tp>
constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
template <typename _Tp>
constexpr bool is_empty_v = is_empty<_Tp>::value;
template <typename _Tp>
constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
template <typename _Tp>
constexpr bool is_abstract_v = is_abstract<_Tp>::value;
template <typename _Tp>
constexpr bool is_final_v = is_final<_Tp>::value;
template <typename _Tp>
constexpr bool is_signed_v = is_signed<_Tp>::value;
template <typename _Tp>
constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
template <typename _Tp, typename... _Args>
constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
template <typename _Tp>
constexpr bool is_default_constructible_v =
is_default_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
template <typename _Tp, typename _Up>
constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
template <typename _Tp>
constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_destructible_v = is_destructible<_Tp>::value;
template <typename _Tp, typename... _Args>
constexpr bool is_trivially_constructible_v =
is_trivially_constructible<_Tp, _Args...>::value;
template <typename _Tp>
constexpr bool is_trivially_default_constructible_v =
is_trivially_default_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_copy_constructible_v =
is_trivially_copy_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_move_constructible_v =
is_trivially_move_constructible<_Tp>::value;
template <typename _Tp, typename _Up>
constexpr bool is_trivially_assignable_v =
is_trivially_assignable<_Tp, _Up>::value;
template <typename _Tp>
constexpr bool is_trivially_copy_assignable_v =
is_trivially_copy_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_move_assignable_v =
is_trivially_move_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_trivially_destructible_v =
is_trivially_destructible<_Tp>::value;
template <typename _Tp, typename... _Args>
constexpr bool is_nothrow_constructible_v =
is_nothrow_constructible<_Tp, _Args...>::value;
template <typename _Tp>
constexpr bool is_nothrow_default_constructible_v =
is_nothrow_default_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_nothrow_copy_constructible_v =
is_nothrow_copy_constructible<_Tp>::value;
template <typename _Tp>
constexpr bool is_nothrow_move_constructible_v =
is_nothrow_move_constructible<_Tp>::value;
template <typename _Tp, typename _Up>
constexpr bool is_nothrow_assignable_v =
is_nothrow_assignable<_Tp, _Up>::value;
template <typename _Tp>
constexpr bool is_nothrow_copy_assignable_v =
is_nothrow_copy_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_nothrow_move_assignable_v =
is_nothrow_move_assignable<_Tp>::value;
template <typename _Tp>
constexpr bool is_nothrow_destructible_v =
is_nothrow_destructible<_Tp>::value;
template <typename _Tp>
constexpr bool has_virtual_destructor_v =
has_virtual_destructor<_Tp>::value;
// See C++14 §20.10.5, type property queries
template <typename _Tp>
constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
template <typename _Tp>
constexpr size_t rank_v = rank<_Tp>::value;
template <typename _Tp, unsigned _Idx = 0>
constexpr size_t extent_v = extent<_Tp, _Idx>::value;
// See C++14 §20.10.6, type relations
template <typename _Tp, typename _Up>
constexpr bool is_same_v = is_same<_Tp, _Up>::value;
template <typename _Base, typename _Derived>
constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
template <typename _From, typename _To>
constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
// 3.3.2, Other type transformations
// invocation_type (still unimplemented)
// raw_invocation_type (still unimplemented)
// invocation_type_t (still unimplemented)
// raw_invocation_type_t (still unimplemented)
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace fundamentals_v1
inline namespace fundamentals_v2
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_experimental_detect 201505
// [meta.detect]
template<typename...> using void_t = void;
struct nonesuch
{
nonesuch() = delete;
~nonesuch() = delete;
nonesuch(nonesuch const&) = delete;
void operator=(nonesuch const&) = delete;
};
template<template<typename...> class _Op, typename... _Args>
using is_detected
= typename std::__detector<nonesuch, void, _Op, _Args...>::value_t;
template<template<typename...> class _Op, typename... _Args>
constexpr bool is_detected_v = is_detected<_Op, _Args...>::value;
template<template<typename...> class _Op, typename... _Args>
using detected_t
= typename std::__detector<nonesuch, void, _Op, _Args...>::type;
template<typename _Default, template<typename...> class _Op, typename... _Args>
using detected_or = std::__detected_or<_Default, _Op, _Args...>;
template<typename _Default, template<typename...> class _Op, typename... _Args>
using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type;
template<typename Expected, template<typename...> class _Op, typename... _Args>
using is_detected_exact = is_same<Expected, detected_t<_Op, _Args...>>;
template<typename Expected, template<typename...> class _Op, typename... _Args>
constexpr bool is_detected_exact_v
= is_detected_exact<Expected, _Op, _Args...>::value;
template<typename _To, template<typename...> class _Op, typename... _Args>
using is_detected_convertible
= is_convertible<detected_t<_Op, _Args...>, _To>;
template<typename _To, template<typename...> class _Op, typename... _Args>
constexpr bool is_detected_convertible_v
= is_detected_convertible<_To, _Op, _Args...>::value;
#define __cpp_lib_experimental_logical_traits 201511
template<typename... _Bn>
struct conjunction
: __and_<_Bn...>
{ };
template<typename... _Bn>
struct disjunction
: __or_<_Bn...>
{ };
template<typename _Pp>
struct negation
: __not_<_Pp>
{ };
template<typename... _Bn>
constexpr bool conjunction_v
= conjunction<_Bn...>::value;
template<typename... _Bn>
constexpr bool disjunction_v
= disjunction<_Bn...>::value;
template<typename _Pp>
constexpr bool negation_v
= negation<_Pp>::value;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace fundamentals_v2
} // namespace experimental
} // namespace std
#endif // __cplusplus <= 201103L
#endif // _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS