From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2007-05-11 18:57:27


Richard Hadsell wrote:

> This is a bit off-topic, but you might consult Stroustrup. In his "The
> C++ Programming Language" (3rd or Special edition) he says in section
> 11.2, in reference to operator. and 2 others that can't be overloaded:
> "They take a name, rather than a value, as their second operand and
> provide the means of referring to members. Allowing them to be
> overloaded would lead to subtleties."

Easy fix: use functors.

obj.func(); would actually do

struct anonymous_1
{
     /* some compile-time reflection info here */
     typedef boost::mpl::vector_c<char, 'f', 'u', 'n', 'c'> name;
     static const bool function = true;
     typedef boost::mpl::vector<> args;

     template<typename T>
     auto operator(T& t) -> decltype(t.func())
     {
         return t.func()
     }
};

obj.operator.(anonymous_1());

I think this would allow, for example, to directly call the member
functions of the underlying object in boost.variant.
Could someone confirm that?