Skip to content

Instantly share code, notes, and snippets.

@allstarschh
Created November 14, 2017 08:31
Show Gist options
  • Save allstarschh/2dd093d5817b9f5fc57057c2d9cd2c98 to your computer and use it in GitHub Desktop.
Save allstarschh/2dd093d5817b9f5fc57057c2d9cd2c98 to your computer and use it in GitHub Desktop.
#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