Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename T, int int_param> struct dispatch_demo {
- void do_the_job_impl(int_v<0>)
- {
- std::cout << "zero" << std::endl;
- }
- void do_the_job_impl(int_v<1>)
- {
- std::cout << "one" << std::endl;
- }
- template <int v> void do_the_job_impl(int_v<v>)
- {
- std::cout << "generic" << std::endl;
- }
- void do_the_job()
- {
- do_the_job_impl(int_v<int_param>());
- }
- };
- int main() {
- dispatch_demo<int, 0> d0;
- dispatch_demo<int, 1> d1;
- dispatch_demo<int, 2> d2;
- d0.do_the_job();
- d1.do_the_job();
- d2.do_the_job();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement