Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Template function declaration to avoid usage of template in T::template f<int>()
struct A { template <class T> void f() {} }; #define solve 4 //0: fails, 1...4: different ways to solve it (clang accepts only 1 (except 3.0: accepts 1...4); VS accepts all, incl. 0; GCC accepts 1...4 (except GCC14: doen't accept 3) #if solve==3 template <class T> float f(float); #endif struct C { #if solve==4 template <class T> C* f(C*); #endif }; struct B : public C { template <class T> static void g(T& in) { #if solve==1 in.template f<int>(); #else in.f<int>(); #endif } template <class T> #if solve==2 static void f(T& in) #else static void h(T& in) #endif { #if solve==1 in.template f<int>(); #else in.f<int>(); #endif } }; int main() { A a; B b; b.g<A>(a); }
run
|
edit
|
history
|
help
0
Progress bar
C++ string format
Adaptive return type
Dequeue Using STL List
Dynamically sized array at end of struct
dharmesh
sharedptr emptiness
narrow_cast
For NULL-embedded strings, CStringT::Find() produces what you may not expect
MSVC_example_GetAllocLength