explicit specialization

error C2912: explicit specialization; 'void bdi<box>(box &,box &)' is not a specialization of a function template.


1
2
  template <typename T> T bdi(T a, T b);
  template <> void bdi<box>(box & a, box & b);


box is a struct type. And where wrong?
Functions have overloading.
void bdi( box & a, box & b );
i found it. the return type and argument problem.
Last edited on
I would've thought it's because you're passing a reference in your attempt at a specialisation.
it's because the T should be box&, and in <> i give "box", so it's not consistent.
another problem is that the return type, explicit and original template should be consistent, in my opinion.

so
template <typename T> T bdi(T, T);
template <> box& bdi<box&>(box& a, box& b);

or
template <typename T> T bdi(T&, T&);
template <> box bdi<box>(box&, box&);
:)
Last edited on
Overload, don't specialize:

1
2
template <typename T> T bdi(T a, T b);
void bdi(box & a, box & b);


http://www.cplusplus.com/forum/beginner/100227/#msg538872
ok, i'll check it later, dinner time :)
Topic archived. No new replies allowed.