Wild Compile Errors with ptime member
I am running Boost 1.33.0 and compiling wiht MinGW. When I compile
the following source file
=========================
#include "boost/shared_ptr.hpp"
#include "boost/test/test_tools.hpp"
#include "boost/date_time/posix_time/posix_time_types.hpp"
class foo {
public:
foo() {}
~foo() {}
boost::posix_time::ptime mExecutionStart;
};
class foo_test {
foo_test();
~foo_test();
void run();
};
void foo_test::run() {
boost::shared_ptr<foo> testObj(new foo());
BOOST_CHECK_EQUAL(testObj->mExecutionStart,
testObj->mExecutionStart);
};
=================================
I get the (lengthy) compiler error output below. As you can see,
something seems to be trying to log something to an output
stream.
The test compile just fine as long as the BOOST_CHECK_EQUAL()
doesn't reference a boost::posix_time::ptime variables.
Any ideas?
Merrill Cornish
=================================
E:/Dev-Cpp/Workflow/boost/include/boost/test/test_tools.hpp: In member function `void boost::test_tools::tt_detail::print_log_value<T>::operator()(std::ostream&, const T&) [with T = boost::posix_time::ptime]':
E:/Dev-Cpp/Workflow/boost/include/boost/test/test_tools.hpp:372: instantiated from `std::ostream& boost::test_tools::tt_detail::operator<<(std::ostream&, const boost::test_tools::tt_detail::print_helper_t<T>&) [with T = boost::posix_time::ptime]'
E:/Dev-Cpp/Workflow/boost/include/boost/test/utils/wrap_stringstream.hpp:66: instantiated from `boost::basic_wrap_stringstream<CharT>& boost::operator<<(boost::basic_wrap_stringstream<CharT>&, const T&) [with CharT = char, T = boost::test_tools::tt_detail::print_helper_tboost::posix_time::ptime]'
E:/Dev-Cpp/Workflow/boost/include/boost/test/test_tools.hpp:427: instantiated from `void boost::test_tools::tt_detail::check_frwd(Pred, boost::wrap_stringstream&, boost::test_tools::const_string, size_t, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, const Arg0&, const char*, const Arg1&, const char*) [with Pred = boost::test_tools::tt_detail::equal_impl_frwd, Arg0 = boost::posix_time::ptime, Arg1 = boost::posix_time::ptime]'
E:/Dev-Cpp/Workflow/test/src/TimeDemo.cc:19: instantiated from here
E:/Dev-Cpp/Workflow/boost/include/boost/test/test_tools.hpp:274: error: no match for 'operator<<' in 'ostr << t'
E:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:63: note: candidates are: std::basic_ostream
I am running Boost 1.33.0 and compiling wiht MinGW. When I compile the following source file
========================= #include "boost/shared_ptr.hpp" #include "boost/test/test_tools.hpp" #include "boost/date_time/posix_time/posix_time_types.hpp"
class foo { public: foo() {} ~foo() {} boost::posix_time::ptime mExecutionStart; };
class foo_test { foo_test(); ~foo_test(); void run(); };
void foo_test::run() { boost::shared_ptr<foo> testObj(new foo()); BOOST_CHECK_EQUAL(testObj->mExecutionStart, testObj->mExecutionStart); }; =================================
I get the (lengthy) compiler error output below. As you can see, something seems to be trying to log something to an output stream.
The test compile just fine as long as the BOOST_CHECK_EQUAL() doesn't reference a boost::posix_time::ptime variables.
Any ideas?
Merrill Cornish
=================================
E:/Dev-Cpp/Workflow/boost/include/boost/test/test_tools.hpp: In member function `void boost::test_tools::tt_detail::print_log_value<T>::operator()(std::ostream&, const T&) [with T = boost::posix_time::ptime]': E:/Dev-Cpp/Workflow/boost/include/boost/test/test_tools.hpp:372: instantiated from `std::ostream& boost::test_tools::tt_detail::operator<<(std::ostream&, const boost::test_tools::tt_detail::print_helper_t<T>&) [with T = boost::posix_time::ptime]' E:/Dev-Cpp/Workflow/boost/include/boost/test/utils/wrap_stringstream.hpp:66: instantiated from `boost::basic_wrap_stringstream<CharT>& boost::operator<<(boost::basic_wrap_stringstream<CharT>&, const T&) [with CharT = char, T = boost::test_tools::tt_detail::print_helper_tboost::posix_time::ptime]' E:/Dev-Cpp/Workflow/boost/include/boost/test/test_tools.hpp:427: instantiated from `void boost::test_tools::tt_detail::check_frwd(Pred, boost::wrap_stringstream&, boost::test_tools::const_string, size_t, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, const Arg0&, const char*, const Arg1&, const char*) [with Pred = boost::test_tools::tt_detail::equal_impl_frwd, Arg0 = boost::posix_time::ptime, Arg1 = boost::posix_time::ptime]' E:/Dev-Cpp/Workflow/test/src/TimeDemo.cc:19: instantiated from here E:/Dev-Cpp/Workflow/boost/include/boost/test/test_tools.hpp:274: error: no match for 'operator<<' in 'ostr << t'
You need an output operator << for the boost::posix_time::ptime to be able to print values in test log. Gennadiy
On 1/3/06 5:32 PM, "Gennadiy Rozental"
You need an output operator << for the boost::posix_time::ptime to be able to print values in test log.
Or you can put this line:
BOOST_TEST_DONT_PRINT_LOG_VALUE( boost::posix_time::ptime );
at the file level before the first test that uses ptime. It will indicate
that ptime is unprintable. But any test macro that has the value and try to
print it will print out empty space instead. However, looking at the
Date-Time docs, ptime should have I/O operators. Make sure to #include
participants (3)
-
Daryle Walker
-
Gennadiy Rozental
-
Merrill Cornish