Standard library header <concepts> (C++20)
From cppreference.net
このヘッダは concepts ライブラリの一部です。
Concepts |
|
コア言語コンセプト |
|
|
(C++20)
|
型が別の型と同じであることを指定する
(concept) |
|
(C++20)
|
ある型が別の型から派生していることを指定する
(concept) |
|
(C++20)
|
ある型が別の型に暗黙的に変換可能であることを指定する
(concept) |
|
(C++20)
|
2つの型が共通の参照型を共有することを指定する
(コンセプト) |
|
(C++20)
|
2つの型が共通の型を共有することを指定する
(コンセプト) |
|
(C++20)
|
型が整数型であることを指定する
(concept) |
|
(C++20)
|
型が符号付き整数型であることを指定する
(コンセプト) |
|
(C++20)
|
型が符号なし整数型であることを指定する
(コンセプト) |
|
(C++20)
|
型が浮動小数点型であることを指定する
(concept) |
|
(C++20)
|
ある型が別の型から代入可能であることを指定する
(コンセプト) |
|
(C++20)
|
型が交換可能であること、または2つの型が互いに交換可能であることを指定する
(concept) |
|
(C++20)
|
その型のオブジェクトが破棄可能であることを指定する
(concept) |
|
(C++20)
|
その型の変数が引数型のセットから構築可能、またはバインド可能であることを指定する
(コンセプト) |
|
(C++20)
|
ある型のオブジェクトがデフォルト構築可能であることを指定する
(コンセプト) |
|
(C++20)
|
ある型のオブジェクトがムーブ構築可能であることを指定する
(concept) |
|
(C++20)
|
型のオブジェクトがコピー構築およびムーブ構築可能であることを指定する
(concept) |
比較コンセプト |
|
|
operator
==
が同値関係であることを指定する
(コンセプト) |
|
|
その型の比較演算子が全順序を生成することを指定する
(concept) |
|
オブジェクト概念 |
|
|
(C++20)
|
型のオブジェクトが移動および交換可能であることを指定する
(concept) |
|
(C++20)
|
型のオブジェクトがコピー、ムーブ、スワップ可能であることを指定する
(コンセプト) |
|
(C++20)
|
ある型のオブジェクトがコピー、ムーブ、交換、デフォルト構築可能であることを指定する
(コンセプト) |
|
(C++20)
|
型がregularであることを指定します。つまり、型が
semiregular
かつ
equality_comparable
の両方であることを意味します
(コンセプト) |
Callable コンセプト |
|
|
(C++20)
|
指定された引数型のセットで呼び出し可能な型を指定する
(concept) |
|
(C++20)
|
呼び出し可能な型がブーリアン述語であることを指定する
(コンセプト) |
|
(C++20)
|
呼び出し可能な型が二項関係であることを指定する
(concept) |
|
(C++20)
|
関係が同値関係を課すことを指定する
relation
(コンセプト) |
|
(C++20)
|
ある
relation
が厳密弱順序を課すことを指定する
(コンセプト) |
カスタマイゼーションポイントオブジェクト |
|
|
(C++20)
|
2つのオブジェクトの値を交換する
(カスタマイゼーションポイントオブジェクト) |
概要
// すべてフリースタンディング namespace std { // 言語関連コンセプト // concept same_as template<class T, class U> concept same_as = /* see description */; // concept derived_from template<class Derived, class Base> concept derived_from = /* see description */; // concept convertible_to template<class From, class To> concept convertible_to = /* see description */; // concept common_reference_with template<class T, class U> concept common_reference_with = /* see description */; // concept common_with template<class T, class U> concept common_with = /* see description */; // 算術コンセプト template<class T> concept integral = /* see description */; template<class T> concept signed_integral = /* see description */; template<class T> concept unsigned_integral = /* see description */; template<class T> concept floating_point = /* see description */; // concept assignable_from template<class LHS, class RHS> concept assignable_from = /* see description */; // concept swappable namespace ranges { inline namespace /* unspecified */ { inline constexpr /* unspecified */ swap = /* unspecified */; } } template<class T> concept swappable = /* see description */; template<class T, class U> concept swappable_with = /* see description */; // concept destructible template<class T> concept destructible = /* see description */; // concept constructible_from template<class T, class... Args> concept constructible_from = /* see description */; // concept default_initializable template<class T> concept default_initializable = /* see description */; // concept move_constructible template<class T> concept move_constructible = /* see description */; // concept copy_constructible template<class T> concept copy_constructible = /* see description */; // 比較コンセプト // concept equality_comparable template<class T> concept equality_comparable = /* see description */; template<class T, class U> concept equality_comparable_with = /* see description */; // concept totally_ordered template<class T> concept totally_ordered = /* see description */; template<class T, class U> concept totally_ordered_with = /* see description */; // オブジェクトコンセプト 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 */; // 呼び出し可能コンセプト // concept invocable template<class F, class... Args> concept invocable = /* see description */; // concept regular_invocable template<class F, class... Args> concept regular_invocable = /* see description */; // concept predicate template<class F, class... Args> concept predicate = /* see description */; // concept relation template<class R, class T, class U> concept relation = /* see description */; // concept equivalence_relation template<class R, class T, class U> concept equivalence_relation = /* see description */; // concept strict_weak_order template<class R, class T, class U> concept strict_weak_order = /* see description */; }
ヘルパーコンセプト
boolean-testable
template<class T> concept /*boolean-testable-impl*/ = convertible_to<T, bool>; // 説明専用; template<class T> concept boolean-testable = // 説明専用 /*boolean-testable-impl*/<T> && requires(T&& t) { { !std::forward<T>(t) } -> /*boolean-testable-impl*/; };
コンセプト
same_as
template<class T, class U> concept /*same-as-impl*/ = is_same_v<T, U>; // 説明専用 template<class T, class U> concept same_as = /*same-as-impl*/<T, U> && /*same-as-impl*/<U, T>;
Concept
derived_from
template<class Derived, class Base> concept derived_from = is_base_of_v<Base, Derived> && is_convertible_v<const volatile Derived*, const volatile Base*>;
コンセプト
convertible_to
template<class From, class To> concept convertible_to = is_convertible_v<From, To> && requires { static_cast<To>(declval<From>()); };
Concept
common_reference_with
template<class T, class U> concept common_reference_with = same_as<common_reference_t<T, U>, common_reference_t<U, T>> && convertible_to<T, common_reference_t<T, U>> && convertible_to<U, common_reference_t<T, U>>;
Concept
common_with
template<class T, class U> concept common_with = same_as<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>()); } && common_reference_with<add_lvalue_reference_t<const T>, add_lvalue_reference_t<const U>> && common_reference_with< 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>;
コンセプト
signed_integral
template<class T> concept signed_integral = integral<T> && is_signed_v<T>;
コンセプト
unsigned_integral
template<class T> concept unsigned_integral = integral<T> && !signed_integral<T>;
コンセプト
floating_point
template<class T> concept floating_point = is_floating_point_v<T>;
コンセプト
assignable_from
template<class LHS, class RHS> concept assignable_from = is_lvalue_reference_v<LHS> && common_reference_with<const remove_reference_t<LHS>&, const remove_reference_t<RHS>&> && requires(LHS lhs, RHS&& rhs) { { lhs = std::forward<RHS>(rhs) } -> same_as<LHS>; };
コンセプト
swappable
template<class T> concept swappable = requires(T& a, T& b) { ranges::swap(a, b); };
コンセプト
swappable_with
template<class T, class U> concept swappable_with = common_reference_with<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_from
template<class T, class... Args> concept constructible_from = destructible<T> && is_constructible_v<T, Args...>;
Concept
default_initializable
template<class T> constexpr bool /*is-default-initializable*/ = /* 説明を参照 */; // 説明専用 template<class T> concept default_initializable = constructible_from<T> && requires { T{}; } && /*is-default-initializable*/<T>;
コンセプト
move_constructible
template<class T> concept move_constructible = constructible_from<T, T> && convertible_to<T, T>;
コンセプト
copy_constructible
template<class T> concept copy_constructible = move_constructible<T> && constructible_from<T, T&> && convertible_to<T&, T> && constructible_from<T, const T&> && convertible_to<const T&, T> && constructible_from<T, const T> && convertible_to<const T, T>;
コンセプト
equality_comparable
template<class T, class U> concept /*weakly-equality-comparable-with*/ = // 説明専用 requires(const remove_reference_t<T>& t, const remove_reference_t<U>& u) { { t == u } -> boolean-testable; { t != u } -> boolean-testable; { u == t } -> boolean-testable; { u != t } -> boolean-testable; }; template<class T> concept equality_comparable = /*weakly-equality-comparable-with*/<T, T>;
コンセプト
equality_comparable_with
template<class T, class U, class C = common_reference_t<const T&, const U&>> concept /*comparison-common-type-with-impl*/ = // 説明専用 same_as<common_reference_t<const T&, const U&>, common_reference_t<const U&, const T&>> && requires { requires convertible_to<const T&, const C&> || convertible_to<T, const C&>; requires convertible_to<const U&, const C&> || convertible_to<U, const C&>; }; template<class T, class U> concept /*comparison-common-type-with*/ = // 説明専用 /*comparison-common-type-with-impl*/<remove_cvref_t<T>, remove_cvref_t<U>>; template<class T, class U> concept equality_comparable_with = equality_comparable<T> && equality_comparable<U> && /*comparison-common-type-with*/<T, U> && equality_comparable< common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>> && /*weakly-equality-comparable-with*/<T, U>;
ヘルパーコンセプト partially-ordered-with
定義済みヘッダ <compare>
template<class T, class U> concept /*部分的順序付け*/ = // 説明専用 requires(const remove_reference_t<T>& t, const remove_reference_t<U>& u) { { t < u } -> boolean-testable; { t > u } -> boolean-testable; { t <= u } -> boolean-testable; { t >= u } -> boolean-testable; { u < t } -> boolean-testable; { u > t } -> boolean-testable; { u <= t } -> boolean-testable; { u >= t } -> boolean-testable; };
コンセプト
totally_ordered
template<class T> concept totally_ordered = equality_comparable<T> && /*partially-ordered-with*/<T, T>;
コンセプト
totally_ordered_with
template<class T, class U> concept totally_ordered_with = totally_ordered<T> && totally_ordered<U> && equality_comparable_with<T, U> && totally_ordered< common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>> && /*部分的順序関係*/<T, U>;
コンセプト
movable
template<class T> concept movable = is_object_v<T> && move_constructible<T> && assignable_from<T&, T> && swappable<T>;
コンセプト
copyable
template<class T> concept copyable = copy_constructible<T> && movable<T> && assignable_from<T&, T&> && assignable_from<T&, const T&> && assignable_from<T&, const T>;
コンセプト
semiregular
template<class T> concept semiregular = copyable<T> && default_initializable<T>;
コンセプト
regular
template<class T> concept regular = semiregular<T> && equality_comparable<T>;
コンセプト
invocable
template<class F, class... Args> concept invocable = requires(F&& f, Args&&... args) { invoke(std::forward<F>(f), std::forward<Args>(args)...); // 等価性を保持する必要はない };
コンセプト
regular_invocable
template<class F, class... Args> concept regular_invocable = invocable<F, Args...>;
コンセプト
predicate
template<class F, class... Args> concept predicate = regular_invocable<F, Args...> && boolean-testable<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>;
コンセプト
equivalence_relation
template<class R, class T, class U> concept equivalence_relation = relation<R, T, U>;
コンセプト
strict_weak_order
template<class R, class T, class U> concept strict_weak_order = relation<R, T, U>;