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
Heap: insert and deleteMin() Implementations
11/29
LOOL
Variable declarations in while loop conditions are also C++-only.
New wall
regex
void pointer
numeric_limits
6 7
INHERIT_CTORS default constructor