Boost logo

Boost :

From: Roman Yakovenko (roman.yakovenko_at_[hidden])
Date: 2005-11-27 02:56:33


Good morning.

Consider next use case:

struct my_ldt : public boost::local_time::local_date_time_base<>{
my_ldt()
: boost::local_time::local_date_time_base<>( boost::posix_time::ptime()
    , boost::shared_ptr< boost::date_time::time_zone_base<boost::posix_time::ptime> >() )
{}

};

int _tmain(int argc, _TCHAR* argv[])
{
    boost::posix_time::ptime t;
    my_ldt m;
    m == t;
    //^^^^^^^^
    //this will not compile ( at least on VC 7.1 )
   //the error is error C2678: binary '==' : no operator found which takes a left-hand operand of type 'my_ldt' (or there is no acceptable conversion)
}

fix:

Add next code to the local_date_time_base class

   typedef date_time::base_time<utc_time_, boost::posix_time::posix_time_system> base_type;

   using base_type::operator==;
   using base_type::operator<;
   using base_type::operator-;

Thanks

Roman Yakovenko


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