The Boost Chrono Documentation says that it is possible to use the chrono library as a header only library. I don't see anything that mentions the limitations to using it as a header only library. Besides the obvious difference of not needing to link against boost_chrono, what changes when I define the BOOST_CHRONO_HEADER_ONLY macro?
I am interesting in using the library for the the chrono_io features. I would prefer to use the header only version but want to know what I lose by doing so. If there isn't any difference why does the linked version exist?
#define BOOST_CHRONO_VERSION 2
#include <boost/chrono.hpp>
#include <boost/chrono/chrono_io.hpp>
int main(int argc, char **argv)
{
const auto now = boost::chrono::system_clock::now();
std::cout << "It is now "
<< boost::chrono::time_fmt(boost::chrono::timezone::local)
<< now << "\n";
}
Compiled with
g++ -std=c++11 -o chronoLinked main.cpp -lboost_system -lboost_chrono
g++ -std=c++11 -o chrono main.cpp -lboost_system -D BOOST_CHRONO_HEADER_ONLY
Running both produces the same output with the current time.