22 #ifndef GEARS_CONCEPTS_BASIC_HPP
23 #define GEARS_CONCEPTS_BASIC_HPP
31 struct is_lvalue_swappable {
32 template<
typename T,
typename U>
33 static auto test(
int) -> decltype(
std::swap(std::declval<LRef<T>>(), std::declval<LRef<U>>()), std::true_type{}) {}
35 static std::false_type test(...);
38 struct is_rvalue_swappable {
39 template<
typename T,
typename U>
40 static auto test(
int) -> decltype(
std::swap(std::declval<RRef<T>>(), std::declval<RRef<U>>()), std::true_type{}) {}
42 static std::false_type test(...);
165 struct Movable : And<MoveAssignable<T>, MoveConstructible<T>> {};
184 struct Copyable : And<CopyAssignable<T>, CopyConstructible<T>> {};
203 struct Assignable : And<MoveAssignable<T>, CopyAssignable<T>> {};
235 template<
typename T,
typename... Args>
267 struct POD : std::is_pod<Bare<T>> {};
281 struct Semiregular : And<Movable<T>, Copyable<T>, DefaultConstructible<T>> {};
294 template<
typename T,
typename U = T>
308 template<
typename T,
typename U = T>
322 template<
typename T,
typename U = T>
323 struct Swappable : And<LValueSwappable<T, U>, RValueSwappable<T, U>> {};
510 struct is_less_than_comparable {
511 template<
typename T,
typename U,
512 typename LT = decltype(std::declval<T&>() < std::declval<U&>()),
513 TrueIf<ContextualBool<LT>>...>
514 static std::true_type test(
int);
515 template<
typename...>
516 static std::false_type test(...);
519 struct is_equality_comparable {
520 template<
typename T,
typename U,
521 typename EQ = decltype(std::declval<T&>() == std::declval<U&>()),
522 typename NE = decltype(std::declval<T&>() != std::declval<U&>()),
523 TrueIf<ContextualBool<EQ>, ContextualBool<NE>>...>
524 static std::true_type test(
int);
525 template<
typename...>
526 static std::false_type test(...);
529 struct is_comparable {
530 template<
typename T,
typename U,
531 typename LT = decltype(std::declval<T&>() < std::declval<U&>()),
532 typename LE = decltype(std::declval<T&>() <= std::declval<U&>()),
533 typename GT = decltype(std::declval<T&>() > std::declval<U&>()),
534 typename GE = decltype(std::declval<T&>() >= std::declval<U&>()),
535 TrueIf<ContextualBool<LT>, ContextualBool<LE>, ContextualBool<GT>, ContextualBool<GE>>...>
536 static std::true_type test(
int);
537 template<
typename...>
538 static std::false_type test(...);
541 template<
typename Po
inter>
542 struct is_np_assignable_impl {
545 std::nullptr_t np =
nullptr;
546 const std::nullptr_t npc =
nullptr;
548 static const bool one = std::is_same<Pointer&, decltype(a = np)>();
549 static const bool two = std::is_same<Pointer&, decltype(a = npc)>();
550 static const bool three = Constructible<Pointer, std::nullptr_t>();
551 static const bool four = Constructible<Pointer, const std::nullptr_t>();
552 static const bool value = one && two && three && four;
556 struct is_np_assign : std::integral_constant<bool, is_np_assignable_impl<T>::value> {};
558 struct is_incrementable {
560 typename Po = decltype(std::declval<T&>().
operator++(0)),
561 typename Pr = decltype(std::declval<T&>().
operator++()),
562 TrueIf<std::is_same<Pr, LRef<T>>>...>
563 static std::true_type test(
int);
564 template<
typename...>
565 static std::false_type test(...);
568 struct is_decrementable {
570 typename Po = decltype(std::declval<T&>().
operator--(0)),
571 typename Pr = decltype(std::declval<T&>().
operator--()),
572 TrueIf<std::is_same<Pr, LRef<T>>>...>
573 static std::true_type test(
int);
574 template<
typename...>
575 static std::false_type test(...);
578 struct is_dereferenceable {
580 typename Re = decltype(std::declval<T&>().
operator*()),
581 typename Ar = decltype(std::declval<T&>().operator->())>
582 static std::true_type test(
int);
583 template<
typename...>
584 static std::false_type test(...);
609 template<
typename T,
typename U = T>
634 template<
typename T,
typename U = T>
675 template<
typename T,
typename U = T>
713 CopyConstructible<T>,
717 EqualityComparable<T, std::nullptr_t>,
718 EqualityComparable<std::nullptr_t, T>,
719 detail::is_np_assign<T>> {};
739 struct Incrementable : Or<Fundamental<T>, Pointer<T>, TraitOf<detail::is_incrementable, T>> {};
759 struct Decrementable : Or<Fundamental<T>, Pointer<T>, TraitOf<detail::is_decrementable, T>> {};
784 #endif // GEARS_CONCEPTS_BASIC_HPP