#include <iostream>
#include <type_traits>
#define rigid constexpr
template< class T >
rigid typename std::remove_reference< T >::type dref( T && t )
{
return t;
}
#define is_rigid( c ) noexcept( dref( c ) )
using namespace std;
int main()
{
int a = 0;
const int b = 0;
constexpr int c = 0;
const int d = a;
cout << boolalpha;
cout << is_rigid( a ) << endl;
cout << is_rigid( b ) << endl;
cout << is_rigid( c ) << endl;
cout << is_rigid( d ) << endl;
return 0;
}
결과는
false
true
true
false
어제 쓴 리터럴 상수 이야기를 코드로 표현해봄.
std::is_literal_type 이랑은 용도가 다른것에 유의~
저 remove_const reference 이런거랑 is_~~로 정적타입 구분하는거 이런거 한번 정리해줘서 올려주시면 졸라 고마울것같음
응 할게 많아서 생각해볼게유~