$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] default argument and call trait const_reference
From: Hicham Mouline (hicham_at_[hidden])
Date: 2009-04-09 09:52:39
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,