5

I would like to conditionally compile a member of a class based on it's class template parameter. I have convenience functions that only make sense to the compiler in certain conditions so I'd like for the compiler to skip them if I can programmatically determine when this is so.

// T is a mathematical type
template <typename T>
class Foo {
public:
    // when zero is not clearly defined
    void bar(T a, T b, T zero) {

    }

    // only makes sense if 0 can be cast to T
    // will fail otherwise
    void bar(T a, T b) {
        bar(a, b, 0);
    } 
}
  • I am using VS2012, so sadly, no default member template parameters. :(

What is the best way to achieve what I want?

PythonNut
  • 6,182
  • 1
  • 25
  • 41

0 Answers0