// -*- C++ -*-
//===-------------------------- type_traits -------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
#define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS

/**
    experimental/type_traits synopsis

// C++1y
#include <type_traits>

namespace std {
namespace experimental {
inline namespace fundamentals_v1 {

  // See C++14 20.10.4.1, primary type categories
  template <class T> constexpr bool is_void_v
    = is_void<T>::value;
  template <class T> constexpr bool is_null_pointer_v
    = is_null_pointer<T>::value;
  template <class T> constexpr bool is_integral_v
    = is_integral<T>::value;
  template <class T> constexpr bool is_floating_point_v
    = is_floating_point<T>::value;
  template <class T> constexpr bool is_array_v
    = is_array<T>::value;
  template <class T> constexpr bool is_pointer_v
    = is_pointer<T>::value;
  template <class T> constexpr bool is_lvalue_reference_v
    = is_lvalue_reference<T>::value;
  template <class T> constexpr bool is_rvalue_reference_v
    = is_rvalue_reference<T>::value;
  template <class T> constexpr bool is_member_object_pointer_v
    = is_member_object_pointer<T>::value;
  template <class T> constexpr bool is_member_function_pointer_v
    = is_member_function_pointer<T>::value;
  template <class T> constexpr bool is_enum_v
    = is_enum<T>::value;
  template <class T> constexpr bool is_union_v
    = is_union<T>::value;
  template <class T> constexpr bool is_class_v
    = is_class<T>::value;
  template <class T> constexpr bool is_function_v
    = is_function<T>::value;

  // See C++14 20.10.4.2, composite type categories
  template <class T> constexpr bool is_reference_v
    = is_reference<T>::value;
  template <class T> constexpr bool is_arithmetic_v
    = is_arithmetic<T>::value;
  template <class T> constexpr bool is_fundamental_v
    = is_fundamental<T>::value;
  template <class T> constexpr bool is_object_v
    = is_object<T>::value;
  template <class T> constexpr bool is_scalar_v
    = is_scalar<T>::value;
  template <class T> constexpr bool is_compound_v
    = is_compound<T>::value;
  template <class T> constexpr bool is_member_pointer_v
    = is_member_pointer<T>::value;

  // See C++14 20.10.4.3, type properties
  template <class T> constexpr bool is_const_v
    = is_const<T>::value;
  template <class T> constexpr bool is_volatile_v
    = is_volatile<T>::value;
  template <class T> constexpr bool is_trivial_v
    = is_trivial<T>::value;
  template <class T> constexpr bool is_trivially_copyable_v
    = is_trivially_copyable<T>::value;
  template <class T> constexpr bool is_standard_layout_v
    = is_standard_layout<T>::value;
  template <class T> constexpr bool is_pod_v
    = is_pod<T>::value;
  template <class T> constexpr bool is_literal_type_v
    = is_literal_type<T>::value;
  template <class T> constexpr bool is_empty_v
    = is_empty<T>::value;
  template <class T> constexpr bool is_polymorphic_v
    = is_polymorphic<T>::value;
  template <class T> constexpr bool is_abstract_v
    = is_abstract<T>::value;
  template <class T> constexpr bool is_final_v
    = is_final<T>::value;
  template <class T> constexpr bool is_signed_v
    = is_signed<T>::value;
  template <class T> constexpr bool is_unsigned_v
    = is_unsigned<T>::value;
  template <class T, class... Args> constexpr bool is_constructible_v
    = is_constructible<T, Args...>::value;
  template <class T> constexpr bool is_default_constructible_v
    = is_default_constructible<T>::value;
  template <class T> constexpr bool is_copy_constructible_v
    = is_copy_constructible<T>::value;
  template <class T> constexpr bool is_move_constructible_v
    = is_move_constructible<T>::value;
  template <class T, class U> constexpr bool is_assignable_v
    = is_assignable<T, U>::value;
  template <class T> constexpr bool is_copy_assignable_v
    = is_copy_assignable<T>::value;
  template <class T> constexpr bool is_move_assignable_v
    = is_move_assignable<T>::value;
  template <class T> constexpr bool is_destructible_v
    = is_destructible<T>::value;
  template <class T, class... Args> constexpr bool is_trivially_constructible_v
    = is_trivially_constructible<T, Args...>::value;
  template <class T> constexpr bool is_trivially_default_constructible_v
    = is_trivially_default_constructible<T>::value;
  template <class T> constexpr bool is_trivially_copy_constructible_v
    = is_trivially_copy_constructible<T>::value;
  template <class T> constexpr bool is_trivially_move_constructible_v
    = is_trivially_move_constructible<T>::value;
  template <class T, class U> constexpr bool is_trivially_assignable_v
    = is_trivially_assignable<T, U>::value;
  template <class T> constexpr bool is_trivially_copy_assignable_v
    = is_trivially_copy_assignable<T>::value;
  template <class T> constexpr bool is_trivially_move_assignable_v
    = is_trivially_move_assignable<T>::value;
  template <class T> constexpr bool is_trivially_destructible_v
    = is_trivially_destructible<T>::value;
  template <class T, class... Args> constexpr bool is_nothrow_constructible_v
    = is_nothrow_constructible<T, Args...>::value;
  template <class T> constexpr bool is_nothrow_default_constructible_v
    = is_nothrow_default_constructible<T>::value;
  template <class T> constexpr bool is_nothrow_copy_constructible_v
    = is_nothrow_copy_constructible<T>::value;
  template <class T> constexpr bool is_nothrow_move_constructible_v
    = is_nothrow_move_constructible<T>::value;
  template <class T, class U> constexpr bool is_nothrow_assignable_v
    = is_nothrow_assignable<T, U>::value;
  template <class T> constexpr bool is_nothrow_copy_assignable_v
    = is_nothrow_copy_assignable<T>::value;
  template <class T> constexpr bool is_nothrow_move_assignable_v
    = is_nothrow_move_assignable<T>::value;
  template <class T> constexpr bool is_nothrow_destructible_v
    = is_nothrow_destructible<T>::value;
  template <class T> constexpr bool has_virtual_destructor_v
    = has_virtual_destructor<T>::value;

  // See C++14 20.10.5, type property queries
  template <class T> constexpr size_t alignment_of_v
    = alignment_of<T>::value;
  template <class T> constexpr size_t rank_v
    = rank<T>::value;
  template <class T, unsigned I = 0> constexpr size_t extent_v
    = extent<T, I>::value;

  // See C++14 20.10.6, type relations
  template <class T, class U> constexpr bool is_same_v
    = is_same<T, U>::value;
  template <class Base, class Derived> constexpr bool is_base_of_v
    = is_base_of<Base, Derived>::value;
  template <class From, class To> constexpr bool is_convertible_v
    = is_convertible<From, To>::value;

  // 3.3.2, Other type transformations
  template <class> class invocation_type; // not defined
  template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>;
  template <class> class raw_invocation_type; // not defined
  template <class F, class... ArgTypes> class raw_invocation_type<F(ArgTypes...)>;

  template <class T>
    using invocation_type_t = typename invocation_type<T>::type;
  template <class T>
    using raw_invocation_type_t = typename raw_invocation_type<T>::type;

  // 3.3.3, Logical operator traits
  template<class... B> struct conjunction;
  template<class... B> constexpr bool conjunction_v = conjunction<B...>::value;
  template<class... B> struct disjunction;
  template<class... B> constexpr bool disjunction_v = disjunction<B...>::value;
  template<class B> struct negation;
  template<class B> constexpr bool negation_v = negation<B>::value;

  // 3.3.4, Detection idiom
  template <class...> using void_t = void;

  struct nonesuch {
    nonesuch() = delete;
    ~nonesuch() = delete;
    nonesuch(nonesuch const&) = delete;
    void operator=(nonesuch const&) = delete;
  };

  template <template<class...> class Op, class... Args>
    using is_detected = see below;
  template <template<class...> class Op, class... Args>
    constexpr bool is_detected_v = is_detected<Op, Args...>::value;
  template <template<class...> class Op, class... Args>
    using detected_t = see below;
  template <class Default, template<class...> class Op, class... Args>
    using detected_or = see below;
  template <class Default, template<class...> class Op, class... Args>
    using detected_or_t = typename detected_or<Default, Op, Args...>::type;
  template <class Expected, template<class...> class Op, class... Args>
    using is_detected_exact = is_same<Expected, detected_t<Op, Args...>>;
  template <class Expected, template<class...> class Op, class... Args>
    constexpr bool is_detected_exact_v
      = is_detected_exact<Expected, Op, Args...>::value;
  template <class To, template<class...> class Op, class... Args>
     using is_detected_convertible = is_convertible<detected_t<Op, Args...>, To>;
  template <class To, template<class...> class Op, class... Args>
     constexpr bool is_detected_convertible_v
       = is_detected_convertible<To, Op, Args...>::value;  

} // namespace fundamentals_v1
} // namespace experimental
} // namespace std

 */

#include <experimental/__config>

#if _LIBCPP_STD_VER > 11

#include <type_traits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_LFTS

#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES

// C++14 20.10.4.1, primary type categories

template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
    = is_void<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
    = is_null_pointer<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
    = is_integral<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
    = is_floating_point<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
    = is_array<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
    = is_pointer<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
    = is_lvalue_reference<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
    = is_rvalue_reference<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
    = is_member_object_pointer<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
    = is_member_function_pointer<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
    = is_enum<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
    = is_union<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
    = is_class<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
    = is_function<_Tp>::value;

// C++14 20.10.4.2,  composite type categories

template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
    = is_reference<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
    = is_arithmetic<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
    = is_fundamental<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
    = is_object<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
    = is_scalar<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
    = is_compound<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
    = is_member_pointer<_Tp>::value;

// C++14 20.10.4.3, type properties

template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
    = is_const<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
    = is_volatile<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
    = is_trivial<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
    = is_trivially_copyable<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
    = is_standard_layout<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
    = is_pod<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
    = is_literal_type<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
    = is_empty<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
    = is_polymorphic<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
    = is_abstract<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
    = is_final<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
    = is_signed<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
    = is_unsigned<_Tp>::value;

template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v
    = is_constructible<_Tp, _Ts...>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
    = is_default_constructible<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
    = is_copy_constructible<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
    = is_move_constructible<_Tp>::value;

template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v
    = is_assignable<_Tp, _Up>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
    = is_copy_assignable<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
    = is_move_assignable<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
    = is_destructible<_Tp>::value;

template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
    = is_trivially_constructible<_Tp, _Ts...>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
    = is_trivially_default_constructible<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
    = is_trivially_copy_constructible<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
    = is_trivially_move_constructible<_Tp>::value;

template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
    = is_trivially_assignable<_Tp, _Up>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
    = is_trivially_copy_assignable<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
    = is_trivially_move_assignable<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
    = is_trivially_destructible<_Tp>::value;

template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
    = is_nothrow_constructible<_Tp, _Ts...>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
    = is_nothrow_default_constructible<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
    = is_nothrow_copy_constructible<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
    = is_nothrow_move_constructible<_Tp>::value;

template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
    = is_nothrow_assignable<_Tp, _Up>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
    = is_nothrow_copy_assignable<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
    = is_nothrow_move_assignable<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
    = is_nothrow_destructible<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
    = has_virtual_destructor<_Tp>::value;

// C++14 20.10.5, type properties queries

template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
    = alignment_of<_Tp>::value;

template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
    = rank<_Tp>::value;

template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v
    = extent<_Tp, _Id>::value;

// C++14 20.10.6, type relations

template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
    = is_same<_Tp, _Up>::value;

template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v
    = is_base_of<_Tp, _Up>::value;

template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
    = is_convertible<_Tp, _Up>::value;

#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */

// 3.3.2, Other type transformations
/*
template <class>
class _LIBCPP_TEMPLATE_VIS raw_invocation_type;

template <class _Fn, class ..._Args>
class _LIBCPP_TEMPLATE_VIS raw_invocation_type<_Fn(_Args...)>;

template <class>
class _LIBCPP_TEMPLATE_VIS invokation_type;

template <class _Fn, class ..._Args>
class _LIBCPP_TEMPLATE_VIS invokation_type<_Fn(_Args...)>;

template <class _Tp>
using invokation_type_t = typename invokation_type<_Tp>::type;

template <class _Tp>
using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
*/

// 3.3.3, Logical operator traits
template <class...> using void_t = void;

template <class... _Args>
struct conjunction : _VSTD::__and_<_Args...> {};
template <class... _Args>
_LIBCPP_CONSTEXPR bool conjunction_v = conjunction<_Args...>::value;

template <class... _Args>
struct disjunction : _VSTD::__or_<_Args...> {};
template <class... _Args>
_LIBCPP_CONSTEXPR bool disjunction_v = disjunction<_Args...>::value;

template <class _Tp>
struct negation : _VSTD::__not_<_Tp> {};
template<class _Tp>
_LIBCPP_CONSTEXPR bool negation_v = negation<_Tp>::value;

// 3.3.4, Detection idiom
template <class...> using void_t = void;

struct nonesuch {
    nonesuch()  = delete;
    ~nonesuch() = delete;
    nonesuch      (nonesuch const&) = delete;
    void operator=(nonesuch const&) = delete;
  };

template <class _Default, class _AlwaysVoid, template <class...> class _Op, class... _Args>
struct _DETECTOR {
   using value_t = false_type;
   using type = _Default;
   };

template <class _Default, template <class...> class _Op, class... _Args>
struct _DETECTOR<_Default, void_t<_Op<_Args...>>, _Op, _Args...> {
   using value_t = true_type;
   using type = _Op<_Args...>;
   };
     

template <template<class...> class _Op, class... _Args>
  using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t;
template <template<class...> class _Op, class... _Args>
  using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type;
template <template<class...> class _Op, class... _Args>
  _LIBCPP_CONSTEXPR bool is_detected_v = is_detected<_Op, _Args...>::value;

template <class Default, template<class...> class _Op, class... _Args>
  using detected_or = _DETECTOR<Default, void, _Op, _Args...>;
template <class Default, template<class...> class _Op, class... _Args>
  using detected_or_t = typename detected_or<Default, _Op, _Args...>::type;

template <class Expected, template<class...> class _Op, class... _Args>
  using is_detected_exact = is_same<Expected, detected_t<_Op, _Args...>>;
template <class Expected, template<class...> class _Op, class... _Args>
  _LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact<Expected, _Op, _Args...>::value;

template <class To, template<class...> class _Op, class... _Args>
  using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, To>;
template <class To, template<class...> class _Op, class... _Args>
  _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<To, _Op, _Args...>::value;  


_LIBCPP_END_NAMESPACE_LFTS

#endif /* _LIBCPP_STD_VER > 11 */

#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */
