Notice
Recent Posts
Recent Comments
목록sfinae (1)
NeuroWhAI의 잡블로그
[C++] std::void_t를 이용해 클래스에 특정 멤버가 있는지 확인하기.
※ 아래 내용은 스택오버플로의 글을 공부하고 정리한 내용이므로 틀린 내용이 있을 수 있습니다. 템플릿 메타프로그래밍을 이용해서 특정 타입에 특정 멤버가 있는지 컴파일 타임에 확인할 수 있는 방법이 있습니다.일단 코드부터 보시죠. #include #include template struct has_member_foo : std::false_type { }; template struct has_member_foo : std::true_type { }; class Bar { public: int bar; }; class Foo { public: explicit Foo(int); int foo; }; int main() { using namespace std; cout
개발 및 공부/언어
2018. 8. 5. 21:07