diff --git a/include/cereal/archives/json.hpp b/include/cereal/archives/json.hpp index d7451247..9b485be6 100644 --- a/include/cereal/archives/json.hpp +++ b/include/cereal/archives/json.hpp @@ -106,14 +106,25 @@ namespace cereal void saveValue(double d) { itsWriter.Double(d); } void saveValue(std::string const & s) { itsWriter.String(s.c_str(), static_cast( s.size() )); } void saveValue(char const * s) { itsWriter.String(s); } + #ifdef _MSC_VER + // Visual Studio has problems disambiguating the above for unsigned long, so we provide an explicit + // overload for long and serialize it as its size necessitates + // + // When loading we don't need to do this specialization since we catch the types with + // templates according to their size + + //! 32 bit long saving template inline typename std::enable_if::type saveLong(T lu){ saveValue( static_cast( lu ) ); } + + //! non 32 bit long saving template inline typename std::enable_if::type saveLong(T lu){ saveValue( static_cast( lu ) ); } + //! MSVC only long overload void saveValue( unsigned long lu ){ saveLong( lu ); }; #endif diff --git a/performance.cpp b/performance.cpp index c02c8208..c5a58976 100644 --- a/performance.cpp +++ b/performance.cpp @@ -200,18 +200,18 @@ void test( std::string const & name, std::cout << " Boost results:" << std::endl; std::cout << boost::format("\tsave | time: %06.4fms (%1.2f) size: %20.8fkb (%1.8f) total: %6.1fms") - % averageBoostSave % 1.0 % (boostSize / 1024.0) % 1.0 % static_cast( totalBoostSave.count() ); + % averageBoostSave % 1.0 % (boostSize / 1024.0) % 1.0 % static_cast( std::chrono::duration_cast(totalBoostSave).count() ); std::cout << std::endl; std::cout << boost::format("\tload | time: %06.4fms (%1.2f) total: %6.1fms") - % averageBoostLoad % 1.0 % static_cast( totalBoostLoad.count() ); + % averageBoostLoad % 1.0 % static_cast( std::chrono::duration_cast(totalBoostLoad).count() ); std::cout << std::endl; std::cout << " Cereal results:" << std::endl; std::cout << boost::format("\tsave | time: %06.4fms (%1.2f) size: %20.8fkb (%1.8f) total: %6.1fms") - % averageCerealSave % cerealSaveP % (cerealSize / 1024.0) % cerealSizeP % static_cast( totalCerealSave.count() ); + % averageCerealSave % cerealSaveP % (cerealSize / 1024.0) % cerealSizeP % static_cast( std::chrono::duration_cast(totalCerealSave).count() ); std::cout << std::endl; std::cout << boost::format("\tload | time: %06.4fms (%1.2f) total: %6.1fms") - % averageCerealLoad % cerealLoadP % static_cast( totalCerealLoad.count() ); + % averageCerealLoad % cerealLoadP % static_cast( std::chrono::duration_cast(totalCerealLoad).count() ); std::cout << std::endl; }