AMDG On 02/27/2013 04:08 PM, Chris Stankevitz wrote:
Can you modify the attached program so that the object TCPositionTraits holds all the traits for the TCPosition object. Not just the traits for the "double" parameters, as is currently the case. Notably missing from TCPositionTraits is a reference to TCPosition::mSteps.
That's actually pretty easy:
change TCDoubleTraits, TCUnsignedTraits, etc. to
template<class T>
struct TCTraits;
template<>
struct TCTraits<double>;
template<>
struct TCTraits<unsigned>;
change
struct TSItem { ... };
to
template<class T>
struct TSItemImpl
{
const TCTraits<T> *mTraits;
boost::function
Difficulty:
This is a difficult question to answer due to the fact that TCPositionTraits has hard-coded in it the keyword "double". I cannot figure out how to remove this.
Bonus:
Bonus points if your answer looks something like "yes it is possible if you start using a boost concept which you apparently are not aware of".
Note:
You'll need the C++11 brace-initialization capability to compile this. I used "g++ -std=c++0x test.cpp" with gcc 4.6.3.
In Christ, Steven Watanabe