Boost logo

Boost :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2005-09-09 01:22:18


On Sep 9, 2005, at 3:04 AM, Robert Ramey wrote:

> David Abrahams wrote:
>
>>> I did - it compiles fine with VC 7.1, Commeau 4.3, Borland 5.64, and
>>> gcc 3.3
>>>
>> Well, I clearly wouldn't have posted it if I couldn't get it to fail.
>>
>
> Well, you might have made a mistake.

Here's an example that fails on more compilers:

         namespace me
          {
           class X {};
         }

         namespace boost { namespace serialization
         {

           void serialize(double);

           template <class T>
           int call_serialize(T const& x)
           {
              serialize(x);
              return 0;
           }

           void serialize(me::X);

         }}

         int y = boost::serialization::call_serialize(me::X());

Note the extra serialize function declared before call_serialize. The
IBM xlC compiler issues helpful error messages confirming Dave's point:

"test.C", line 14.24: 1540-0256 (S) A parameter of type "double"
cannot be initialized with an expression of type "const me::X".
"test.C", line 14.24: 1540-1205 (I) The error occurred while
converting to parameter 1 of "boost::serialization::serialize(double)".
"test.C", line 18.16: 1540-1298 (I) "void serialize(me::X)" needs to
be declared in the containing scope to be found by name lookup.
"test.C", line 12.15: 1540-0700 (I) The previous message was produced
while processing "boost::serialization::call_serialize<me::X>(const X
&)".
"test.C", line 22.17: 1540-0700 (I) The previous message was produced
while processing "y".

I hope this helps you understand what is going on,

Matthias


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk