Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2004-02-22 06:14:51


I found following issue: if I have const type in a list of types test case
template facility initialized with, it really gets instantiated with non
const type. After some investigation I found the reason. The reason is the
mpl::for_each, used in the facility implementation, rely on type deduction
based on type of single argument it passes. It works for simple function and
function object. But it does not for function object with template
operator(). It's all originated from the fact that following code compiles:

struct {
    template<typename T>
    void operator()( T )
        T t = 0;
} foo;

int main()
    char const x = 0;

    foo( x );

    return 0;

because foo.operator() is instantiated with type char - not char const.

Is the any workarounds? Could we fix that?


P.S. Actually I was concerned with this unused parameter from the very
beginning. It prohibit using for_each with types without default constructor
and also could be source for performance problems. Could we eliminate this
unused parameter at all?

Boost list run by bdawes at, gregod at, cpdaniel at, john at