Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
compile-time check of existness of method of a class
//g++ 4.9.3 #include <iostream> using yes_meta_t = char; using no_meta_t = char[2]; template <typename T> yes_meta_t& func(T const& obj, decltype(&T::method) = &T::method); template <typename T> no_meta_t& func(...); class X { public: void method(int, int) { } }; int main() { std::cout << std::boolalpha; std::cout << (sizeof(func<X>(std::declval<X>())) == sizeof(yes_meta_t)) << std::endl; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Barnicle
floyd alfa 1
Set Insert Operation
Beadandó
Inherit
Collatz Conjecture
Empty C++ Script
MyString
Abejas beta
single_digit
Please log in to post a comment.