Boost logo

Boost Users :

Subject: Re: [Boost-users] default argument and call trait const_reference
From: Hicham Mouline (hicham_at_[hidden])
Date: 2009-04-09 10:11:13


>Hello,
>I have the following template
>template<typename C>
>class X
>{
>public:
> template<typename Interp, typename Extrap>
> void Get (int,
> typename boost::call_traits<Interp>::const_reference=
>Interp(),
> typename boost::call_traits<Extrap>::const_reference=
>Extrap() ) const;
>};
>template<typename C>
>template<typename Interp, typename Extrap>
>inline void X<C>::Get(int, typename
>boost::call_traits<Interp>::const_reference i,
> typename boost::call_traits<Extrap>::const_reference e ) {
> // when I get here,
> i.mOrder is not 2 (0)
> e.mOrder is not 2 (23142343)
>}
>class P {
>public:
> static const size_t defaultInterpolationOrder = 2; // quadratic
>polynomial
   
> Polynomial1D(size_t order =defaultInterpolationOrder)
> : mOrder(order)
> {}
>Private:
> size_t mOrder;
>};
>1 example of call is
> x.template GetSpot<P,P>( 5 );
>when I debug this P's ctor is never called and mOrder is never 2
>Is my GetSpot method valid, the construction of the temporary should be
>bound to the const ref
> const P&
>and the temporary should have finished being constructed before we go
inside
>the Get() method.
>Is there an issue with the definition of Get being out of classe?
>Am I calling call_traits<P>::const_reference in a wrong way?
>VS2005SP1
>Regards,

I've just corrected call_traits<>::const_reference to
const_reference<>::param_type
because I am dealing with function parameters here, and I still have the
same problem.

Rds,


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net