c++ - In boost::posix_time, how to construct time_duration from volatile time_duration? -
i'm trying compile code:
#include <boost/date_time.hpp> using boost::posix_time::time_duration; int main() { volatile time_duration t0; time_duration t1 = t0; return 0; }
with command:
g++ test01.cpp -std=c++11 -i /boost_1_55_0/ -o test01
and error:
test01.cpp:6:22: error: no matching function call ‘boost::posix_time::time_duration::time_duration(volatile boost::posix_time::time_duration&)
i'm using gcc 4.8.2; idea how fix this?
this due a gcc bug. workaround so:
volatile time_duration t0; time_duration t1 = const_cast<time_duration&>(t0);
it works because const_cast
can remove volatility constness. i'm not sure how strictly safe is, mind you.
an alternative fix rid of volatile
in first place; serves purpose nowadays.
Comments
Post a Comment