Thanks. Code is below. Member operator *() branches to a template functor which specializes for arithmetic type, and leaves the rest undefined. Later, the operator * still cannot be overloaded, but the as yet undefined cases of the template functor are available to be defined. So that is how the problem is solved. I didn't want to use inheritance as that could profoundly affect performance. (In the atual code, A is a point type and Z is an affine transformation type. I want to be able to write a * z0 * z1 * z3, etc.Otherwise I have to define Z * A and write z3 * (z2 * (z1*a))) to bring about the same computation.) [I also wanted to key the return type using type traits, but the compiler complained about invalid template argument list, but that's another story]. Craig Hicks John Maddock wrote:
I know how to use type traits to enable compile time seperate procedures, but not how to use it to define a procedure for some type and not others.
One way (for member functions) is to use inheritance: add an "implementation layer" that includes the member function or not depending on whether a trait is true or not:
template
struct mybase { // details T operator*(); }; template
struct mybase { // details }; template <class T> struct mine : public mybase
{ // details }; Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
#include <iostream>
#include "boost\type_traits.hpp"
///////////////////////////////////////////////////////////////////
template <class T>
struct A
{
T i;
template <class U>
A<T>
operator * (const U& u) const;
};
template