3

I currently have a constructor for a class that is :

template<class TX, class TY> MyClass(const TX &x, const TY &y)

and allow me to construct my class based on 2 values.

I would like to be able to construct my class with random generators/engines from C++ 2011.

template<class TG, class TE> MyClass(TG &generator, TE &engine)

How to modify this last constructor because, in that form, it is the same thing as the first one for the compiler. I think I can use SFINAE but I don't know how.

Thank you very much !

Vincent
  • 57,703
  • 61
  • 205
  • 388

1 Answers1

3

What do the TX and TY arguments represent in the first constructor? To use SFINAE, you have to find some aspect of the APIs of the generator and engine that's reliably distinct from TX and TY, such as a member variable or function. The seed function might be a good candidate. The general techniques for checking for a member function with a known signature are documented in another answer here: Is it possible to write a template to check for a function's existence?

Community
  • 1
  • 1
Tony Delroy
  • 102,968
  • 15
  • 177
  • 252