Namespaces
Variants

std:: reference_converts_from_temporary

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
헤더에 정의됨 <type_traits>
template < class T, class U >
struct reference_converts_from_temporary ;
(C++23부터)

U 가 스칼라 타입이거나 cv 한정된 void 인 경우 V std:: remove_cv_t < U > 로 정의하고, 그렇지 않으면 V U 로 정의합니다. T 가 참조 타입이고, decltype ( e ) V 인 가상의 표현식 e 가 주어졌을 때, 변수 정의 T ref = e ; 가 올바르게 형성되고 임시 객체를 바인딩 하여 ref 에 연결한다면, 멤버 상수 value true 로 제공합니다. 그렇지 않으면 value false 입니다.

만약 T 가 const-이지만 volatile-qualified가 아닌 객체 타입에 대한 lvalue 참조 타입이거나 rvalue 참조 타입인 경우, std:: remove_reference_t < T > std:: remove_reference_t < U > 는 모두 완전한 타입 이거나, cv void 이거나, 경계를 알 수 없는 배열 이어야 합니다; 그렇지 않으면 동작은 정의되지 않습니다.

템플릿의 인스턴스화가 직접적 또는 간접적으로 불완전한 타입에 의존하고, 해당 타입이 가상적으로 완성되었을 때 인스턴스화 결과가 달라질 수 있는 경우, 그 동작은 정의되지 않습니다.

프로그램이 std::reference_converts_from_temporary 또는 std::reference_converts_from_temporary_v 에 대한 특수화를 추가하는 경우, 그 동작은 정의되지 않습니다.

목차

헬퍼 변수 템플릿

template < class T, class U >

inline constexpr bool reference_converts_from_temporary_v =

std :: reference_converts_from_temporary < T, U > :: value ;
(C++23 이후)

std:: integral_constant 로부터 상속됨

멤버 상수

value
[static]
true 만약 T 가 참조 타입이고, U 값이 복사 초기화에서 T 에 바인딩될 수 있으며, 임시 객체가 참조에 바인딩될 경우, false 그 외의 경우
(public static member constant)

멤버 함수

operator bool
객체를 bool 로 변환, value 반환
(public member function)
operator()
(C++14)
value 반환
(public member function)

멤버 타입

타입 정의
value_type bool
type std:: integral_constant < bool , value >

참고 사항

std::reference_converts_from_temporary 는 항상 댕글링 레퍼런스를 생성하는 일부 경우를 거부하는 데 사용될 수 있습니다.

예제

#include <type_traits>
int main() {}
static_assert(
    std::reference_converts_from_temporary_v<int&&, int> == true &&
    std::reference_converts_from_temporary_v<const int&, int> == true &&
    std::reference_converts_from_temporary_v<int&&, int&&> == false &&
    std::reference_converts_from_temporary_v<const int&, int&&> == false &&
    std::reference_converts_from_temporary_v<int&&, long&&> == true &&
    std::reference_converts_from_temporary_v<int&&, long> == true);

참고 항목

한 타입이 다른 타입으로 변환 가능한지 확인합니다
(클래스 템플릿)
(C++17) (C++23)
주어진 인수로 모든 Callable 객체를 호출합니다 반환 타입 지정 가능 (C++23부터)
(함수 템플릿)
(C++11)
함수 객체에 하나 이상의 인수를 바인딩합니다
(함수 템플릿)
(C++17)
하나 이상의 variant 가 보유한 인수로 제공된 함수자를 호출합니다
(함수 템플릿)
새로운 std::function 인스턴스를 생성합니다
( std::function<R(Args...)> 의 공개 멤버 함수)
새로운 std::move_only_function 객체를 생성합니다
( std::move_only_function 의 공개 멤버 함수)
태스크 객체를 생성합니다
( std::packaged_task<R(Args...)> 의 공개 멤버 함수)