You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've implemented a custom save function for std::basic_string_view following the implementation from std::basic_string. Using binary and portable binary archives work without problems (even the tests pass), but when I try to test for the XML and JSON archives I get an compiler error telling me
cereal could not find any output serialization functions for the provided type and archive combination.
I'm using Visual Studio 2019 (16.0.1) with C++17 and x64 config.
My string_view.hpp (basically copy & paste):
#pragma once
#include"../cereal.hpp"
#include<string_view>namespacecereal
{
//! Serialization for basic_string_view types, if binary data is supportedtemplate <classArchive, classCharT, classTraits>
typename std::enable_if<traits::is_output_serializable<BinaryData<CharT>, Archive>::value, void>::type
CEREAL_SAVE_FUNCTION_NAME(Archive& ar, std::basic_string_view<CharT, Traits> const& str)
{
// Save number of chars + the dataar(make_size_tag(static_cast<size_type>(str.size())));
ar(binary_data(str.data(), str.size() * sizeof(CharT)));
}
//! Deserialization into std::basic_string_view is forbidden due to its properties as a view.//! However std::basic_string_view can be deserialized into a std::basic_string.// template <class Archive, class CharT, class Traits>// void CEREAL_LOAD_FUNCTION_NAME(Archive& ar, std::basic_string_view<CharT, Traits> & str);
}
I've implemented a custom save function for
std::basic_string_view
following the implementation fromstd::basic_string
. Using binary and portable binary archives work without problems (even the tests pass), but when I try to test for the XML and JSON archives I get an compiler error telling meI'm using Visual Studio 2019 (16.0.1) with C++17 and x64 config.
My
string_view.hpp
(basically copy & paste):and my test file (I use catch2 instead of boost):
Do I miss something or why doesn't the code compile?
The text was updated successfully, but these errors were encountered: