Created
November 14, 2017 08:31
-
-
Save allstarschh/2dd093d5817b9f5fc57057c2d9cd2c98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <iostream> | |
template <typename T> | |
class Foo { | |
public: | |
bool foo = std::is_pod<T>::value; | |
void clear() { | |
if (foo) { | |
clearPod(); | |
} else { | |
clearNonPod(); | |
} | |
} | |
private: | |
void clearPod() { | |
std::cout<< "clearPod" << std::endl; | |
} | |
void clearNonPod() { | |
std::cout<< "clearNonPod" << std::endl; | |
} | |
}; | |
class Bar { | |
public: | |
Bar() = default; | |
Bar(const Bar& rhs) {} | |
}; | |
int main () | |
{ | |
Foo<int> f; | |
Foo<Bar> g; | |
f.clear(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment