Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
IsContainer
//Title of this code #include <iostream> #include <vector> struct Con { typedef int iterator; iterator begin(); iterator end(); }; template<class T> struct ContainerUser { typedef typename T::iterator iterator; }; template<class T> struct IsContainer { private: class yes { }; class no { yes no[2]; }; template<class A, A, A> struct is_of_type; template<class E> static yes test_value(is_of_type<typename E::iterator(E::*)(), &E::begin, &E::end>*); template<class E> static no test_value(...); public: enum { value = sizeof(test_value<T>(nullptr)) == sizeof(yes) }; }; int main() { typedef int* A; typedef std::vector<int> V; std::cout<<IsContainer<bool>::value<<'\n'; std::cout<<IsContainer<A>::value<<'\n'; std::cout<<IsContainer<V>::value<<'\n'; std::cout<<IsContainer<Con>::value<<'\n'; ContainerUser<Con> b; }
run
|
edit
|
history
|
help
0
regimeketopdfb
Narrowing error
user defined exception
Zadanie Dejwu
Optional conversions
U2
Test titlu
Dash-D compiler flag example
Throttle Example (Send two requests every two seconds)
<string> No indirect include of <errno.h>