Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

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)).

deleted 36 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

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.

Added c++11 tag.
Link
Morwenn
  • 20.2k
  • 3
  • 69
  • 132
Tweeted twitter.com/#!/StackCodeReview/status/449636970319589376
added 433 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
Loading
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /