Boost logo

Boost :

From: Yitzhak Sapir (ysapir_at_[hidden])
Date: 2002-02-05 05:08:29


As I said, I have a problem with call_traits. This problem is very
strange to me. I have gotten a simple piece of code to produce it, but
after getting this far, it seems very very odd. I'm using version 1.25
of the boost libraries.

#include "stdafx.h"
#include "boost/call_traits.hpp"
#include "boost/smart_ptr.hpp"

struct A
{
        virtual const A& getA2() const = 0;
        boost::shared_ptr<A> getA1() const;
};

int main(int argc, char* argv[])
{
        A* a;
#if 1
        a->getA1();
        const A & b = (
                boost::call_traits<const
A&>::param_type(a->getA1()->getA2())
                );
#else
        const A& b = (
                a->getA1(),
                boost::call_traits<const
A&>::param_type(a->getA1()->getA2())
                );
#endif
        return 0;
}

The following produces a series of errors starting with:
c:\testbind\boost\detail\ob_call_traits.hpp(47) : error C2529:
'<Unknown>' : reference to reference is illegal
        c:\testbind\boost\detail\ob_call_traits.hpp(103) : see reference
to class template instantiation
'boost::detail::standard_call_traits<struct TC::TS const &>' being
compiled
        C:\testbind\testct.cpp(21) : see reference to class template
instantiation 'boost::call_traits<struct TC::TS const &>' being compiled

What I find most strange and odd about it is this: If I change the #if 1
to #if 0, I get this error. If I leave the #if 1, it compiles fine (it
doesn't link, but that's not the point). In my code these various parts
represent boolean expressions joined by an &&, and there are three
classes involved, but I tried to get it as simple as possible. So I
could change the code to read: bool b1 = te->getTC(); bool b2 =
te->getTC()->getTS(); and then and them together. But if I try it in
one expression: bool b = te->getTC() && te->getTC()->getTS(); the
compiler fails on the above error.

I am pretty certain this is the error that originally caused my problem.
For some reason, I thought it had to do with a long& at the time. If I
change the long call_traits_chooser expression to be
<is_pointer<>::value, is_reference<>::value), both of the above #if
possibilities work. But I'm not sure this is the root of the problem
anymore.


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