Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
template specialization inheritance solution
//clang 3.8.0 #include <iostream> using namespace std; struct A { A() {} }; struct B : public A { B() {} }; template <typename T, typename = void> struct X{ X(T& t) { cout << "X\n"; } }; template <typename T> struct X<T, typename enable_if<is_base_of<A, T>::value>::type> { X(T& t) { cout << "XA\n"; } }; int main() { cout << boolalpha; cout << is_base_of<A, A>::value << endl; cout << is_base_of<A, B>::value << endl; A a; B b; A& ra = b; X<A> xa(a); X<B> xb(b); X<A> xra(ra); }
run
|
edit
|
history
|
help
0
Composite pattern
Simple Generic Data Type Example
Specialization on signed types
IsContainer
Initialise arrays with N number
Segment Tree Impl
my override
Narrowing error
HTML Timetable generator.cpp
applidiumResto_NicolasCarre