From a previous question previous question I got an answer an answer that included some template magic (that to be blunt was mind-boggling (as I could not understand it)).
From a previous question I got an answer that included some template magic (that to be blunt was mind-boggling (as I could not understand it)).
From a previous question I got an answer that included some template magic (that to be blunt was mind-boggling (as I could not understand it)).
C++ template Rangerange
From a previous question I got an answer that included some template magic (that to be blunt was mind boggling-boggling (as I could not understand it)).
So I have been trying to achieve the same results (because trying helps me learn).
To make sure I have learn correctly I am putting it here for comment. Hopefully it will also help somebody else (and you never know it may encourage me to write a blog post about it).
Any way.
###Version 1 The
The template Codecode I started with:
###Version 2 This
This should be exactly the same.
But we use inheritance to get the type of the terminal class in the recursion. Personally I find this much harder to read than the previous version. But it is more compact.
Any comments on the Range stuff or the test harness welcome.
###Edit 1:
Just realized I can specialize printNumberRange
to take a range directly.
Any comments on the Range stuff or the test harness welcome.
C++ template Range
From a previous question I got an answer that included some template magic (that to be blunt was mind boggling (as I could not understand it)).
So I have been trying to achieve the same results (because trying helps me learn).
To make sure I have learn correctly I am putting it here for comment. Hopefully it will also help somebody else (and you never know it may encourage me to write a blog post about it).
Any way.
###Version 1 The template Code I started with:
###Version 2
This should be exactly the same.
But we use inheritance to get the type of the terminal class in the recursion. Personally I find this much harder to read than the previous version. But it is more compact.
Any comments on the Range stuff or the test harness welcome.
###Edit 1:
Just realized I can specialize printNumberRange
to take a range directly.
C++ template range
From a previous question I got an answer that included some template magic (that to be blunt was mind-boggling (as I could not understand it)).
So I have been trying to achieve the same results (because trying helps me learn).
To make sure I have learn correctly I am putting it here for comment. Hopefully it will also help somebody else (and you never know it may encourage me to write a blog post about it).
###Version 1
The template code I started with:
###Version 2
This should be exactly the same.
But we use inheritance to get the type of the terminal class in the recursion. Personally I find this much harder to read than the previous version. But it is more compact.
I can specialize printNumberRange
to take a range directly.
Any comments on the Range stuff or the test harness welcome.