Standard library header <concepts> (C++20)
From cppreference.net
이 헤더는 concepts 라이브러리의 일부입니다.
Concepts |
|
핵심 언어 개념 |
|
|
(C++20)
|
한 타입이 다른 타입과 동일함을 명시
(concept) |
|
(C++20)
|
한 타입이 다른 타입으로부터 파생되었음을 명시
(concept) |
|
(C++20)
|
한 타입이 다른 타입으로 암시적으로 변환 가능함을 명시
(concept) |
|
(C++20)
|
두 타입이 공통 참조 타입을 공유함을 명시
(concept) |
|
(C++20)
|
두 타입이 공통 타입을 공유함을 명시
(concept) |
|
(C++20)
|
타입이 정수형 타입임을 명시함
(concept) |
|
(C++20)
|
해당 타입이 부호 있는 정수 타입임을 명시합니다
(concept) |
|
(C++20)
|
타입이 부호 없는 정수형임을 명시함
(concept) |
|
(C++20)
|
타입이 부동소수점 타입임을 명시함
(concept) |
|
(C++20)
|
한 타입이 다른 타입으로부터 할당 가능함을 명시
(concept) |
|
(C++20)
|
타입이 교환 가능하거나 두 타입이 서로 교환될 수 있음을 명시
(concept) |
|
(C++20)
|
해당 타입의 객체가 파괴될 수 있음을 명시
(concept) |
|
(C++20)
|
해당 타입의 변수가 일련의 인수 타입들로부터 생성되거나 바인딩될 수 있음을 명시함
(concept) |
|
(C++20)
|
해당 타입의 객체가 기본 생성될 수 있음을 명시함
(concept) |
|
(C++20)
|
해당 타입의 객체가 이동 생성될 수 있음을 명시
(concept) |
|
(C++20)
|
해당 타입의 객체가 복사 생성 및 이동 생성될 수 있음을 명시함
(concept) |
비교 개념 |
|
|
operator
==
가 동치 관계임을 명시함
(concept) |
|
|
해당 타입의 비교 연산자들이 완전 순서를 생성함을 명시
(컨셉) |
|
객체 개념 |
|
|
(C++20)
|
특정 타입의 객체가 이동 및 교환 가능함을 명시
(concept) |
|
(C++20)
|
해당 타입의 객체가 복사, 이동 및 스왑될 수 있음을 명시
(concept) |
|
(C++20)
|
해당 타입의 객체가 복사, 이동, 교환 및 기본 생성될 수 있음을 명시
(concept) |
|
(C++20)
|
어떤 타입이 정규(regular)임을 명시합니다. 즉, 해당 타입이
semiregular
이면서 동시에
equality_comparable
입니다.
(concept) |
Callable 개념 |
|
|
(C++20)
|
호출 가능 타입이 주어진 인수 타입 집합으로 호출될 수 있음을 명시
(concept) |
|
(C++20)
|
호출 가능 타입이 부울 조건자임을 명시합니다
(concept) |
|
(C++20)
|
호출 가능 타입이 이항 관계임을 명시합니다
(concept) |
|
(C++20)
|
relation
이 동치 관계를 부과함을 명시
(concept) |
|
(C++20)
|
relation
이 엄격한 약순서(strict weak ordering)를 부과함을 명시
(concept) |
커스터마이제이션 포인트 객체 |
|
|
(C++20)
|
두 객체의 값을 교환
(커스터마이제이션 포인트 객체) |
시놉시스
// 모든 독립 실행 환경 namespace std { // 언어 관련 개념들 // 개념 same_as template<class T, class U> concept same_as = /* see description */; // 개념 derived_from template<class Derived, class Base> concept derived_from = /* see description */; // 개념 convertible_to template<class From, class To> concept convertible_to = /* see description */; // 개념 common_reference_with template<class T, class U> concept common_reference_with = /* see description */; // 개념 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 */; // 개념 assignable_from template<class LHS, class RHS> concept assignable_from = /* see description */; // 개념 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 */; // 개념 destructible template<class T> concept destructible = /* see description */; // 개념 constructible_from template<class T, class... Args> concept constructible_from = /* see description */; // 개념 default_initializable template<class T> concept default_initializable = /* see description */; // 개념 move_constructible template<class T> concept move_constructible = /* see description */; // 개념 copy_constructible template<class T> concept copy_constructible = /* see description */; // 비교 개념들 // 개념 equality_comparable template<class T> concept equality_comparable = /* see description */; template<class T, class U> concept equality_comparable_with = /* see description */; // 개념 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 */; // 호출 가능 개념들 // 개념 invocable template<class F, class... Args> concept invocable = /* see description */; // 개념 regular_invocable template<class F, class... Args> concept regular_invocable = /* see description */; // 개념 predicate template<class F, class... Args> concept predicate = /* see description */; // 개념 relation template<class R, class T, class U> concept relation = /* see description */; // 개념 equivalence_relation template<class R, class T, class U> concept equivalence_relation = /* see description */; // 개념 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>;
개념
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>()); };
개념
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>>;
개념
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...>;
개념
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 /*약한-동등성-비교-가능*/ = // 설명 전용 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 = /*약한-동등성-비교-가능*/<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> && /*부분적 순서 관계*/<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)...); // 동등성 보존이 요구되지 않음 };
Concept
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>;