I have a member variable in my class:
class Foo
{
// ...
private:
boost::posix_time::ptime t;
}
I want to initialize it in the constructor to a well known value such that I know it hasn't been set by the program yet:
Foo::Foo()
: t(NULL) // doesnt work
{}
But setting it to NULL doesn't work because its not a pointer.
How do I initialize boost::posix_time::ptime
to a well known value?
The default constructor initializes it to
boost::posix_time::not_a_date_time
. There is a member function to check for thatt.is_not_a_date_time()
. For more info see the docs.Demo on Wandbox