编辑:我在 range-v3 GitHub 上发布了一个问题
所以,我正在尝试使用 range-v3 库。但是当我编译我的代码时,它会因错误 C7608 而停止。这是一个相关的片段:
#include "json/single_include/nlohmann/json.hpp"
#include "range-v3/include/range/v3/all.hpp"
class myClass
{
private:
nlohmann::json json_;
public:
auto getJSON() const { return json_; }
};
int main()
{
std::map<int, myClass> patterns_;
auto getJSON = [](const auto &item) { return item.getJSON(); }; //Returns a nlohmann::json
namespace rv = ranges::views;
std::vector<nlohmann::json> jsons = patterns_ | rv::values | rv::transform(getJSON)
| ranges::to_vector;
return 0;
}
编译器输出:
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(228): error C7608: atomic constraint should be a constant expression
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(243): note: see reference to variable template 'bool convertible_to_cont_cont_impl_frag_<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> &,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(257): note: see reference to variable template 'bool convertible_to_cont_cont_impl_<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> &,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(268): note: see reference to variable template 'bool convertible_to_cont_cont_impl_<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> &,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(278): note: see reference to variable template 'bool convertible_to_cont_cont<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> &,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(296): note: see reference to variable template 'bool convertible_to_cont_cont<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> &,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(365): note: see reference to variable template 'bool convertible_to_cont_and_not_cont_cont<meta::id<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> &>' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(228): note: see reference to variable template 'bool invocable<ranges::detail::to_container::fn<meta::id<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> > >,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> &>' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(243): note: see reference to variable template 'bool convertible_to_cont_cont_impl_frag_<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(257): note: see reference to variable template 'bool convertible_to_cont_cont_impl_<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(268): note: see reference to variable template 'bool convertible_to_cont_cont_impl_<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(278): note: see reference to variable template 'bool convertible_to_cont_cont<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(296): note: see reference to variable template 'bool convertible_to_cont_cont<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(365): note: see reference to variable template 'bool convertible_to_cont_and_not_cont_cont<meta::id<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(228): note: see reference to variable template 'bool invocable<ranges::detail::to_container::fn<meta::id<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> > >,nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(243): note: see reference to variable template 'bool convertible_to_cont_cont_impl_frag_<ranges::transform_view<ranges::transform_view<ranges::ref_view<std::map<unsigned int,CAO::PatternSettings,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,CAO::PatternSettings> > > const >,ranges::detail::get_second>,`CAO::PatternMap::getUnifiedJSON'::`2'::<lambda_1> > &,std::vector<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,std::allocator<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> > > >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(257): note: see reference to variable template 'bool convertible_to_cont_cont_impl_<ranges::transform_view<ranges::transform_view<ranges::ref_view<std::map<unsigned int,CAO::PatternSettings,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,CAO::PatternSettings> > > const >,ranges::detail::get_second>,`CAO::PatternMap::getUnifiedJSON'::`2'::<lambda_1> > &,std::vector<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,std::allocator<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> > > >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(268): note: see reference to variable template 'bool convertible_to_cont_cont_impl_<ranges::transform_view<ranges::transform_view<ranges::ref_view<std::map<unsigned int,CAO::PatternSettings,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,CAO::PatternSettings> > > const >,ranges::detail::get_second>,`CAO::PatternMap::getUnifiedJSON'::`2'::<lambda_1> > &,std::vector<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,std::allocator<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> > > >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(278): note: see reference to variable template 'bool convertible_to_cont_cont<ranges::transform_view<ranges::transform_view<ranges::ref_view<std::map<unsigned int,CAO::PatternSettings,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,CAO::PatternSettings> > > const >,ranges::detail::get_second>,`CAO::PatternMap::getUnifiedJSON'::`2'::<lambda_1> > &,std::vector<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,std::allocator<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> > > >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(296): note: see reference to variable template 'bool convertible_to_cont_cont<ranges::transform_view<ranges::transform_view<ranges::ref_view<std::map<unsigned int,CAO::PatternSettings,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,CAO::PatternSettings> > > const >,ranges::detail::get_second>,`CAO::PatternMap::getUnifiedJSON'::`2'::<lambda_1> > &,std::vector<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>,std::allocator<nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer> > > >' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(365): note: see reference to variable template 'bool convertible_to_cont_and_not_cont_cont<ranges::detail::from_range<std::vector>,ranges::transform_view<ranges::transform_view<ranges::ref_view<std::map<unsigned int,CAO::PatternSettings,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,CAO::PatternSettings> > > const >,ranges::detail::get_second>,`CAO::PatternMap::getUnifiedJSON'::`2'::<lambda_1> > &>' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include/libs/json/single_include/nlohmann/json.hpp(22646): note: see reference to class template instantiation 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>' being compiled
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\filesystem(2087): note: see reference to class template instantiation 'std::chrono::time_point<std::filesystem::_File_time_clock,std::chrono::duration<std::chrono::system_clock::rep,std::chrono::system_clock::period>>' being compiled
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\xstring(1743): note: see reference to class template instantiation 'std::basic_string_view<wchar_t,std::char_traits<wchar_t>>' being compiled
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(228): error C2131: expression did not evaluate to a constant
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(228): note: failure was caused by a read of an uninitialized symbol
C:\IT\Code_perso\Cathedral_Assets_Optimizer\include\libs\range-v3\include\range/v3/range/conversion.hpp(228): note: see usage of 'ranges::invocable<ranges::detail::to_container::fn<meta::id<nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>>,nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>&>'
这是完整的项目(所需的库和 CMake 文件)
使用的编译器是带有选项的 MSVC 32 位 16.5(最新)/experimental:preprocessor /std:c++latest /permissive-
有人有想法吗?谢谢