Skip to content

Instantly share code, notes, and snippets.

@MasWag
Created September 17, 2022 01:47
Show Gist options
  • Save MasWag/3c6b8941fae4b7d21fe3163428143fe3 to your computer and use it in GitHub Desktop.
Save MasWag/3c6b8941fae4b7d21fe3163428143fe3 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
template<bool Flag>
class Hello {
public:
void hello() const {
if constexpr (Flag) {
std::cout << "Wahoooo\n";
} else {
std::cout << "Yahoooo\n";
}
}
};
int main(int argc, char *argv[]) {
if (argc > 1) {
const auto hello = Hello<true>();
hello.hello();
} else {
const auto hello = Hello<false>();
hello.hello();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment