Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-05-03 09:19:34

From: "Doug Gregor" <gregod_at_[hidden]>

> On Wednesday 02 May 2001 07:13, you wrote:

> > Heh, they never had partial ordering rules. :-)
> It seems to tell the difference betwee function(const Functor) and
> function(const function&), though barely...

Actually I _think_ that the compiler considers (incorrectly) function(const
function &) a specialization of function(const Functor); this may explain
why it doesn't work with 7.0.

> NO_PARTIAL_ORDERING is defined for Intel C++ 5.0 because of this
> template<typename R, typename T1>
> void foo(R (*f)(T1));
> template<typename Functor>
> void foo(const Functor &f);
> Intel C++ 5.0 handles the partial ordering fine unless you try to give it
> free function with default arguments, i.e., this code will fail on Intel
> because it doesn't order between the two foo() templates:
> int bar(int x, int y = 2);
> foo(&bar);

Yep, I had a deeper look at the code; the problem exists even for function
pointers without default arguments. This ordering is almost an advanced C++
knowledge test.

> Does MSVC 7 actually handle everything if you explicitly use &? I have
> nothing against documenting that people should write clearer code to make
> their compiler work :).

It handles everything fine if I use & in every constructor call _and_ change
the constructor to take "Functor const &". With a "const Functor f" it
cannot find the copy constructor. [I'm not sure whether the assignment
operator uses a direct assignment or constructs a temporary function, but
the test passes.]

Peter Dimov
Multi Media Ltd.

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