標準ライブラリヘッダ <concepts>
提供: cppreference.com
このヘッダはコンセプトライブラリの一部です。
コンセプト | |
コア言語のコンセプト | |
| (C++20) |
型が別の型と同じであることを指定します (コンセプト) |
| (C++20) |
型が別の型から派生していることを指定します (コンセプト) |
| (C++20) |
型が別の型に暗黙に変換可能であることを指定します (コンセプト) |
| (C++20) |
2つの型が共通の参照型を共有することを指定します (コンセプト) |
| (C++20) |
2つの型が共通の型を共有することを指定します (コンセプト) |
| (C++20) |
型が整数型であることを指定します (コンセプト) |
| (C++20) |
型が符号付きの整数型であることを指定します (コンセプト) |
| (C++20) |
型が符号なしの整数型であることを指定します (コンセプト) |
| (C++20) |
型が別の型から代入可能であることを指定します (コンセプト) |
| (C++20) |
型がスワップ可能であること、または2つの型がお互いにスワップ可能であることを指定します (コンセプト) |
| (C++20) |
その型のオブジェクトが破棄可能であることを指定します (コンセプト) |
| (C++20) |
その型の変数が与えられた引数のセットから構築可能または束縛可能であることを指定します (コンセプト) |
| (C++20) |
その型のオブジェクトがデフォルト構築可能であることを指定します (コンセプト) |
| (C++20) |
その型のオブジェクトがムーブ構築可能であることを指定します (コンセプト) |
| (C++20) |
その型のオブジェクトがコピー構築およびムーブ構築可能であることを指定します (コンセプト) |
比較のコンセプト | |
| (C++20) |
型がブーリアンの文脈で使用可能であることを指定します (コンセプト) |
| 演算子 == が同等関係であることを指定します (コンセプト) | |
| 型の比較演算子が全順序を与えることを指定します (コンセプト) | |
オブジェクトのコンセプト | |
| (C++20) |
その型のオブジェクトがムーブおよびスワップ可能であることを指定します (コンセプト) |
| (C++20) |
その型のオブジェクトがコピー、ムーブ、およびスワップ可能であることを指定します (コンセプト) |
| (C++20) |
その型のオブジェクトがコピー、ムーブ、スワップ、およびデフォルト構築可能であることを指定します (コンセプト) |
| (C++20) |
型が普通である、つまり Semiregular かつ EqualityComparable であることを指定します (コンセプト) |
呼び出し可能のコンセプト | |
| (C++20) |
呼び出し可能な型が与えられた引数型のセットで呼び出せることを指定します (コンセプト) |
| (C++20) |
呼び出し可能な型がブーリアンの述語であることを指定します (コンセプト) |
| (C++20) |
呼び出し可能な型が二項関係であることを指定します (コンセプト) |
| (C++20) |
Relation が厳密な弱い順序を課すことを指定します (コンセプト) |
カスタマイゼーションポイントオブジェクト | |
| (C++20) |
2つのオブジェクトの値を入れ替えます (カスタマイゼーションポイントオブジェクト) |
[編集] 概要
namespace std { // Core language concepts template <class T, class U> concept Same = /* see description */; template <class Derived, class Base> concept DerivedFrom = /* see description */; template <class From, class To> concept ConvertibleTo = /* see description */; template <class T, class U> concept CommonReference = /* see description */; template <class T, class U> concept Common = /* see description */; template <class T> concept Integral = /* see description */; template <class T> concept SignedIntegral = /* see description */; template <class T> concept UnsignedIntegral = /* see description */; template <class LHS, class RHS> concept Assignable = /* see description */; namespace ranges { inline namespace /* unspecified */ { inline constexpr /* unspecified */ swap = /* unspecified */; } } template <class T> concept Swappable = /* see description */; template <class T, class U> concept SwappableWith = /* see description */; template <class T> concept Destructible = /* see description */; template <class T, class... Args> concept Constructible = /* see description */; template <class T> concept DefaultConstructible = /* see description */; template <class T> concept MoveConstructible = /* see description */; template <class T> concept CopyConstructible = /* see description */; // Comparison concepts template <class B> concept Boolean = /* see description */; template <class T> concept EqualityComparable = /* see description */; template <class T, class U> concept EqualityComparableWith = /* see description */; template <class T> concept StrictTotallyOrdered = /* see description */; template <class T, class U> concept StrictTotallyOrderedWith = /* see description */; // Object concepts template <class T> concept Movable = /* see description */; template <class T> concept Copyable = /* see description */; template <class T> concept Semiregular = /* see description */; template <class T> concept Regular = /* see description */; // Callable concepts template <class F, class... Args> concept Invocable = /* see description */; template <class F, class... Args> concept RegularInvocable = /* see description */; template <class F, class... Args> concept Predicate = /* see description */; template <class R, class T, class U> concept Relation = /* see description */; template <class R, class T, class U> concept StrictWeakOrder = /* see description */; }
[編集] コンセプト Same
template<class T, class U> concept __SameImpl = is_same_v<T, U>; // exposition only template<class T, class U> concept Same = __SameImpl<T, U> && __SameImpl<U, T>;
[編集] コンセプト DerivedFrom
template<class Derived, class Base> concept DerivedFrom = is_base_of_v<Base, Derived> && is_convertible_v<const volatile Derived*, const volatile Base*>;
[編集] コンセプト ConvertibleTo
template<class From, class To> concept ConvertibleTo = is_convertible_v<From, To> && requires(From (&f)()) { static_cast<To>(f()); };
[編集] コンセプト CommonReference
template<class T, class U> concept CommonReference = Same<common_reference_t<T, U>, common_reference_t<U, T>> && ConvertibleTo<T, common_reference_t<T, U>> && ConvertibleTo<U, common_reference_t<T, U>>;
[編集] コンセプト Common
template<class T, class U> concept Common = Same<common_type_t<T, U>, common_type_t<U, T>> && requires { static_cast<common_type_t<T, U>>(declval<T>()); static_cast<common_type_t<T, U>>(declval<U>()); } && CommonReference< add_lvalue_reference_t<const T>, add_lvalue_reference_t<const U>> && CommonReference< add_lvalue_reference_t<common_type_t<T, U>>, common_reference_t< add_lvalue_reference_t<const T>, add_lvalue_reference_t<const U>>>;
[編集] コンセプト Integral
template<class T> concept Integral = is_integral_v<T>;
[編集] コンセプト SignedIntegral
template<class T> concept SignedIntegral = Integral<T> && is_signed_v<T>;
[編集] コンセプト UnsignedIntegral
template<class T> concept UnsignedIntegral = Integral<T> && !SignedIntegral<T>;
[編集] コンセプト Assignable
template<class LHS, class RHS> concept Assignable = is_lvalue_reference_v<LHS> && CommonReference<const remove_reference_t<LHS>&, const remove_reference_t<RHS>&> && requires(LHS lhs, RHS&& rhs) { { lhs = std::forward<RHS>(rhs) } -> Same<LHS>; };
[編集] コンセプト Swappable
template<class T> concept Swappable = requires(T& a, T& b) { ranges::swap(a, b); };
[編集] コンセプト SwappableWith
template<class T, class U> concept SwappableWith = CommonReference<const remove_reference_t<T>&, const remove_reference_t<U>&> && requires(T&& t, U&& u) { ranges::swap(std::forward<T>(t), std::forward<T>(t)); ranges::swap(std::forward<U>(u), std::forward<U>(u)); ranges::swap(std::forward<T>(t), std::forward<U>(u)); ranges::swap(std::forward<U>(u), std::forward<T>(t)); };
[編集] コンセプト Destructible
template<class T> concept Destructible = is_nothrow_destructible_v<T>;
[編集] コンセプト Constructible
template<class T, class... Args> concept Constructible = Destructible<T> && is_constructible_v<T, Args>;
[編集] コンセプト DefaultConstructible
template<class T> concept DefaultConstructible = Constructible<T>;
[編集] コンセプト MoveConstructible
template<class T> concept MoveConstructible = Constructible<T, T> && ConvertibleTo<T, T>;
[編集] コンセプト CopyConstructible
template<class T> concept CopyConstructible = MoveConstructible<T> && Constructible<T, T&> && ConvertibleTo<T&, T> && Constructible<T, const T&> && ConvertibleTo<const T&, T> && Constructible<T, const T> && ConvertibleTo<const T, T>;
[編集] コンセプト Boolean
template<class B> concept Boolean = Movable<remove_cvref_t<B>> && requires(const remove_reference_t<B>& b1, const remove_reference_t<B>& b2, const bool a) { requires ConvertibleTo<const remove_reference_t<B>&, bool>; { !b1 } -> ConvertibleTo<bool>; { b1 && b2 } -> Same<bool>; { b1 && a } -> Same<bool>; { a && b2 } -> Same<bool>; { b1 || b2 } -> Same<bool>; { b1 || a } -> Same<bool>; { a || b2 } -> Same<bool>; { b1 == b2 } -> ConvertibleTo<bool>; { b1 == a } -> ConvertibleTo<bool>; { a == b2 } -> ConvertibleTo<bool>; { b1 != b2 } -> ConvertibleTo<bool>; { b1 != a } -> ConvertibleTo<bool>; { a != b2 } -> ConvertibleTo<bool>; };
[編集] コンセプト EqualityComparable
template<class T, class U> concept __WeaklyEqualityComparableWith = // exposition only requires(const remove_reference_t<T>& t, const remove_reference_t<U>& u) { { t == u } -> Boolean; { t != u } -> Boolean; { u == t } -> Boolean; { u != t } -> Boolean; }; template<class T> concept EqualityComparable = __WeaklyEqualityComparableWith<T, T>;
[編集] コンセプト EqualityComparableWith
template<class T, class U> concept EqualityComparableWith = EqualityComparable<T> && EqualityComparable<U> && CommonReference<const remove_reference_t<T>&, const remove_reference_t<U>&> && EqualityComparable< common_reference_t< const remove_reference_t<T>&, const remove_reference_t<U>&>> && __WeaklyEqualityComparableWith<T, U>;
[編集] コンセプト StrictTotallyOrdered
template<class T> concept StrictTotallyOrdered = EqualityComparable<T> && requires(const remove_reference_t<T>& a, const remove_reference_t<T>& b) { { a < b } -> Boolean; { a > b } -> Boolean; { a <= b } -> Boolean; { a >= b } -> Boolean; };
[編集] コンセプト StrictTotallyOrderedWith
template<class T, class U> concept StrictTotallyOrderedWith = StrictTotallyOrdered<T> && StrictTotallyOrdered<U> && CommonReference<const remove_reference_t<T>&, const remove_reference_t<U>&> && StrictTotallyOrdered< common_reference_t< const remove_reference_t<T>&, const remove_reference_t<U>&>> && EqualityComparableWith<T, U> && requires(const remove_reference_t<T>& t, const remove_reference_t<U>& u) { { t < u } -> Boolean; { t > u } -> Boolean; { t <= u } -> Boolean; { t >= u } -> Boolean; { u < t } -> Boolean; { u > t } -> Boolean; { u <= t } -> Boolean; { u >= t } -> Boolean; };
[編集] コンセプト Movable
template<class T> concept Movable = is_object_v<T> && MoveConstructible<T> && Assignable<T&, T> && Swappable<T>;
[編集] コンセプト Copyable
template<class T> concept Copyable = CopyConstructible<T> && Movable<T> && Assignable<T&, const T&>;
[編集] コンセプト Semiregular
template<class T> concept Semiregular = Copyable<T> && DefaultConstructible<T>;
[編集] コンセプト Regular
template<class T> concept Regular = Semiregular<T> && EqualityComparable<T>;
[編集] コンセプト Invocable
template<class F, class... Args> concept Invocable = requires(F&& f, Args&&... args) { invoke(std::forward<F>(f), std::forward<Args>(args)...); // not required to be equality-preserving };
[編集] コンセプト RegularInvocable
template<class F, class... Args> concept RegularInvocable = Invocable<F, Args...>;
[編集] コンセプト Predicate
template<class F, class... Args> concept Predicate = RegularInvocable<F, Args...> && Boolean<invoke_result_t<F, Args...>>;
[編集] コンセプト Relation
template<class R, class T, class U> concept Relation = Predicate<R, T, T> && Predicate<R, U, U> && Predicate<R, T, U> && Predicate<R, U, T>;
[編集] コンセプト StrictWeakOrder
template<class R, class T, class U> concept StrictWeakOrder = Relation<R, T, U>;

