Boost logo

Boost :

From: Joe Gottman (jgottman_at_[hidden])
Date: 2007-02-08 20:05:14


   I’ve discovered that you can’t use the arrow operator with an object
of type optional<T &>; For instance , the following code fails:

   vector<double> v;
   optional<vector<double> &> pv(v);
    pv->push_back(2);

The code

   (*pv).push_back(2)

succeeds.

On MSVC 7.1 on Windows XP I get the following error message: (I get a
similar one using gcc 3.4 on Unix).

c:\code\boost\optional\optional.hpp(371) : error C2664:
'boost::optional_detail::optional_base<T>::pointer_const_type
boost::optional_detail::optional_base<T>::cast_ptr(const
boost::optional_detail::optional_base<T>::internal_type
*,boost::optional_detail::optional_base<T>::is_not_reference_tag) const'
: cannot convert parameter 2 from 'boost::integral_constant<bool,true>'
to 'boost::optional_detail::optional_base<T>::is_not_reference_tag'

         with

         [

             T=std::vector<double> &

         ]

         and

         [

             T=std::vector<double> &

         ]

         No constructor could take the source type, or constructor
overload resolution was ambiguous

         c:\code\boost\optional\optional.hpp(371) : while compiling
class-template member function
'boost::optional_detail::optional_base<T>::pointer_type
boost::optional_detail::optional_base<T>::get_ptr_impl(void)'

         with

         [

             T=std::vector<double> &

         ]

         c:\code\boost\optional\optional.hpp(407) : see reference to
class template instantiation 'boost::optional_detail::optional_base<T>'
being compiled

         with

         [

             T=std::vector<double> &

         ]

 
c:\code\Networks\Computations\CppComputations\Forecasting\auto_DFS_2_00_computation.cpp(16)
: see reference to class template instantiation 'boost::optional<T>'
being compiled

         with

         [

             T=std::vector<double> &

         ]

Joe Gottman


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