30분전 쯤 샤워하다가 시작한 생각인데


conditional_t 을 이용해서  원하는 조건이 아니면 컴파일타임 에러나게 


false시 재귀로 계속해서 자기자신을 호출하게 하면 되겠다.



까지 생각해놓고 보니까



uniform_int_distribution같은경우 double 집어넣어놓으면 컴파일 에러띠우던데


STL님은 어떻게 만들어 놨는지 궁금해짐 

따라가 봤더니


1
2
3
4
5
static_assert(
  ((is_integral<_Ty>::value || is_enum<_Ty>::value)
   && !is_same<_Ty, bool>::value),
  "make_signed<T>/make_unsigned<T> require that T shall be a (possibly "
  "cv-qualified) integral type or enumeration but not a bool type.");
cs


요런식으로 에러뜨게 해놓음


is_enum은


1
2
3
4
5
template<class _Ty>
 struct is_enum
  : _Cat_base<__is_enum(_Ty)>
 { // determine whether _Ty is an enumerated type
 };
cs

;


_Cat_base는


1
2
3
4
5
template<bool _Val>
 struct _Cat_base
  : integral_constant<bool, _Val>
 { // base class for type predicates
 };
cs


integral_constant는


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
template<class _Ty,
 _Ty _Val>
 struct integral_constant
 { // convenient template for integral constant types
 static constexpr _Ty value = _Val;
 
 typedef _Ty value_type;
 typedef integral_constant<_Ty, _Val> type;
 
 constexpr operator value_type() const _NOEXCEPT
  { // return stored value
  return (value);
  }
 
 constexpr value_type operator()() const _NOEXCEPT
  { // return stored value
  return (value);
  }
 };
 
cs


뭐 그냥 static 변수인 __is_enum(_Ty)의 결과를 value에다가 집어넣어놓겠다 이런소리고 


정작 중요한건 __is_enum 이거였음 



그런데 모든 헤더를 뒤져봐도 함수 선언,정의를 찾아볼 수 없길래


여기저기 검색해본 결과 내가 찾을 수 없던게 당연한거 마냥 sizeof같은 컴파일러 마법이라고 알려줌;; 

굳이 만들어서 쓰고 싶다면 my__is_enum을 만들어서 일일이 타입비교 해주는 사람도 있더이다.




아무튼 하루 빨리 갓파일러님을 빨리 파헤쳐야 되요.