diff --git a/include/boost/serialization/singleton.hpp b/include/boost/serialization/singleton.hpp index 0df50661..d56cc562 100644 --- a/include/boost/serialization/singleton.hpp +++ b/include/boost/serialization/singleton.hpp @@ -81,29 +81,29 @@ namespace serialization { // attempt to retieve a mutable instances while locked will // generate a assertion if compiled for debug. +// note usage of BOOST_DLLEXPORT. These functions are in danger of +// being eliminated by the optimizer when building an application in +// release mode. Usage of the macro is meant to signal the compiler/linker +// to avoid dropping these functions which seem to be unreferenced. +// This usage is not related to autolinking. + class BOOST_SYMBOL_VISIBLE singleton_module : public boost::noncopyable { private: BOOST_SERIALIZATION_DECL static bool & get_lock(); public: - static void lock(){ + BOOST_DLLEXPORT static void lock(){ get_lock() = true; } - static void unlock(){ + BOOST_DLLEXPORT static void unlock(){ get_lock() = false; } - static bool is_locked(){ + BOOST_DLLEXPORT static bool is_locked(){ return get_lock(); } }; -// note usage of BOOST_DLLEXPORT. These functions are in danger of -// being eliminated by the optimizer when building an application in -// release mode. Usage of the macro is meant to signal the compiler/linker -// to avoid dropping these functions which seem to be unreferenced. -// This usage is not related to autolinking. - template class singleton : public singleton_module { diff --git a/test/test_optional.cpp b/test/test_optional.cpp index 7eb7ee50..6592cdb5 100644 --- a/test/test_optional.cpp +++ b/test/test_optional.cpp @@ -29,10 +29,18 @@ namespace std{ struct A { int m_x; template - void serialize(Archive & ar, const unsigned int version){}; + void serialize(Archive & ar, const unsigned int /* version */){ + ar & boost::serialization::make_nvp("x", m_x); + }; bool operator==(const A & rhs) const { return m_x == rhs.m_x; } + A() : + m_x(0) + {} + A(int x) : + m_x(x) + {} }; int test_main( int /* argc */, char* /* argv */[] ) @@ -43,7 +51,7 @@ int test_main( int /* argc */, char* /* argv */[] ) const boost::optional aoptional1; const boost::optional aoptional2(123); const boost::optional aoptional3; - A a; + A a(1); const boost::optional aoptional4(a); const boost::optional aoptional5; const boost::optional aoptional6(& a);