Skip to main content
Code Review

Return to Question

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

This is a variant of the solution posted here here, without state creation/destruction penalty.

This is a variant of the solution posted here, without state creation/destruction penalty.

This is a variant of the solution posted here, without state creation/destruction penalty.

deleted 251 characters in body; edited tags
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Introduction

This is a variant of the solution posted at State pattern + C++ templatehere, without state creation/destruction penalty. It is also posted as an answer to that question, but @Jamal pointed out that it really was a question in its own right. Since I always blindly obey to people who have a higher reputation than mine, here it comes.

Note that my comment in the original question about the simplification provided by C++11's inherited constructors applies here too, but I have not updated the code in this question accordingly. That is left as an exercise to the reader :-).

The variant

The variant

Anyway, here comes the variant. Please comment on this.

genericstate.hgenericstate.h

machine.hmachine.h

machine.cppmachine.cpp

Introduction

This is a variant of the solution posted at State pattern + C++ template, without state creation/destruction penalty. It is also posted as an answer to that question, but @Jamal pointed out that it really was a question in its own right. Since I always blindly obey to people who have a higher reputation than mine, here it comes.

Note that my comment in the original question about the simplification provided by C++11's inherited constructors applies here too, but I have not updated the code in this question accordingly. That is left as an exercise to the reader :-).

The variant

Anyway, here comes the variant. Please comment.

genericstate.h

machine.h

machine.cpp

This is a variant of the solution posted here, without state creation/destruction penalty.

Note that my comment in the original question about the simplification provided by C++11's inherited constructors applies here too, but I have not updated the code in this question accordingly. That is left as an exercise to the reader.

The variant

Please comment on this.

genericstate.h

machine.h

machine.cpp

deleted 4 characters in body
Source Link
nilo
  • 805
  • 2
  • 7
  • 15

Note that my comment in the original question about the simplification provided by C++11's inherited constructors applies here too, but I have not updated the code in this question correspondinglyaccordingly. That is left as an exercise to the reader :-).

Note that my comment in the original question about the simplification provided by C++11's inherited constructors applies here too, but I have not updated the code in this question correspondingly. That is left as an exercise to the reader :-).

Note that my comment in the original question about the simplification provided by C++11's inherited constructors applies here too, but I have not updated the code in this question accordingly. That is left as an exercise to the reader :-).

Source Link
nilo
  • 805
  • 2
  • 7
  • 15
Loading
lang-cpp

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