Loki-Astari / ThorsSerializer

C++ Serialization library for JSON

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serialize.h:169:88: error: ‘std::index_sequence’ has not been declared

mimre25 opened this issue · comments

Hi, I've managed to install Thor yesterday (after removing all vera++ stuff (--disable-vera didn't work)).

Now I'm trying to use it in my project and I'm getting multiple Errors, starting with the one in the title.

Here is the full log:

In file included from /usr/local/include/ThorSerialize/JsonParser.h:20:0, from /usr/local/include/ThorSerialize/JsonThor.h:14, from /home/mimre/workspace/isosurfaces/json/JSONHandler.h:8, from /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:5: /usr/local/include/ThorSerialize/Serialize.h:169:88: error: ‘std::index_sequence’ has not been declared void scanEachMember(std::string const& key, T& object, Members const& member, std::index_sequence<Seq...> const&); ^~~~~~~~~~~~~~ /usr/local/include/ThorSerialize/Serialize.h:169:102: error: expected ‘,’ or ‘...’ before ‘<’ token void scanEachMember(std::string const& key, T& object, Members const& member, std::index_sequence<Seq...> const&); ^ /usr/local/include/ThorSerialize/Serialize.h:200:71: error: ‘std::index_sequence’ has not been declared void printEachMember(T const& object, Members const& member, std::index_sequence<Seq...> const&); ^~~~~~~~~~~~~~ /usr/local/include/ThorSerialize/Serialize.h:200:85: error: expected ‘,’ or ‘...’ before ‘<’ token void printEachMember(T const& object, Members const& member, std::index_sequence<Seq...> const&); ^ In file included from /usr/local/include/ThorSerialize/Serialize.h:294:0, from /usr/local/include/ThorSerialize/JsonParser.h:20, from /usr/local/include/ThorSerialize/JsonThor.h:14, from /home/mimre/workspace/isosurfaces/json/JSONHandler.h:8, from /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:5: /usr/local/include/ThorSerialize/Serialize.tpp:255:105: error: ‘std::index_sequence’ has not been declared inline void DeSerializer::scanEachMember(std::string const& key, T& object, Members const& member, std::index_sequence<Seq...> const&) ^~~~~~~~~~~~~~ /usr/local/include/ThorSerialize/Serialize.tpp:255:119: error: expected ‘,’ or ‘...’ before ‘<’ token inline void DeSerializer::scanEachMember(std::string const& key, T& object, Members const& member, std::index_sequence<Seq...> const&) ^ /usr/local/include/ThorSerialize/Serialize.tpp: In member function ‘void ThorsAnvil::Serialize::DeSerializer::scanMembers(const string&, T&, const std::tuple<_Elements ...>&)’: /usr/local/include/ThorSerialize/Serialize.tpp:264:42: error: ‘make_index_sequence’ is not a member of ‘std’ scanEachMember(key, object, members, std::make_index_sequence<sizeof...(Members)>()); ^~~ /usr/local/include/ThorSerialize/Serialize.tpp:264:87: error: expected primary-expression before ‘)’ token scanEachMember(key, object, members, std::make_index_sequence<sizeof...(Members)>()); ^ /usr/local/include/ThorSerialize/Serialize.tpp: At global scope: /usr/local/include/ThorSerialize/Serialize.tpp:421:86: error: ‘std::index_sequence’ has not been declared inline void Serializer::printEachMember(T const& object, Members const& member, std::index_sequence<Seq...> const&) ^~~~~~~~~~~~~~ /usr/local/include/ThorSerialize/Serialize.tpp:421:100: error: expected ‘,’ or ‘...’ before ‘<’ token inline void Serializer::printEachMember(T const& object, Members const& member, std::index_sequence<Seq...> const&) ^ /usr/local/include/ThorSerialize/Serialize.tpp: In member function ‘void ThorsAnvil::Serialize::Serializer::printMembers(const T&, const std::tuple<_Elements ...>&)’: /usr/local/include/ThorSerialize/Serialize.tpp:430:38: error: ‘make_index_sequence’ is not a member of ‘std’ printEachMember(object, members, std::make_index_sequence<sizeof...(Members)>()); ^~~ /usr/local/include/ThorSerialize/Serialize.tpp:430:83: error: expected primary-expression before ‘)’ token printEachMember(object, members, std::make_index_sequence<sizeof...(Members)>()); ^ In file included from /usr/local/include/ThorSerialize/Serialize.h:34:0, from /usr/local/include/ThorSerialize/JsonParser.h:20, from /usr/local/include/ThorSerialize/JsonThor.h:14, from /home/mimre/workspace/isosurfaces/json/JSONHandler.h:8, from /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:5: /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp: In member function ‘void json::JSONHandler::saveJSON(RunInformation)’: /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:13:5: error: ‘namespace’ definition is not allowed here ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumens, similarityMaps); ^ /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:13:5: error: static assertion failed: The macro ThorsAnvil_MakeTrait must be used outside all namespace. ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumens, similarityMaps); ^ In file included from /usr/local/include/ThorSerialize/Serialize.h:294:0, from /usr/local/include/ThorSerialize/JsonParser.h:20, from /usr/local/include/ThorSerialize/JsonThor.h:14, from /home/mimre/workspace/isosurfaces/json/JSONHandler.h:8, from /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:5: /usr/local/include/ThorSerialize/Serialize.tpp: In instantiation of ‘class ThorsAnvil::Serialize::SerializerForBlock<(ThorsAnvil::Serialize::TraitType)0, RunInformation>’: /usr/local/include/ThorSerialize/Serialize.tpp:442:48: required from ‘void ThorsAnvil::Serialize::Serializer::print(const T&) [with T = RunInformation]’ /usr/local/include/ThorSerialize/Exporter.h:32:13: required from ‘std::ostream& ThorsAnvil::Serialize::operator<<(std::ostream&, const ThorsAnvil::Serialize::Exporter<ThorsAnvil::Serialize::Json, RunInformation>&)’ /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:18:35: required from here /usr/local/include/ThorSerialize/Serialize.tpp:294:5: error: static assertion failed: Invalid Serialize TraitType. This usually means you have not define ThorsAnvil::Serialize::Traits<Your Type> static_assert( ^~~~~~~~~~~~~

I also was wondering where to put the "ThorsAnvil_MakeTrait"?

Thanks for any help :)

I'm using g++ (Ubuntu 6.2.0-3ubuntu11~14.04) 6.2.0, and have -std=c++14
(I forgot to set the flag previously).
I've run ./configure and it worked fine.

Now i'm just having problems related to the MakeTrait.

In file included from /usr/local/include/ThorSerialize/Serialize.h:34:0, from /usr/local/include/ThorSerialize/JsonParser.h:20, from /usr/local/include/ThorSerialize/JsonThor.h:14, from /home/mimre/workspace/isosurfaces/json/JSONHandler.h:8, from /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:5: /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp: At global scope: /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:11:3: error: ‘Traits’ is not a class template ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumes, similarityMaps); ^ /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:11:3: error: explicit specialization of non-template ‘json::ThorsAnvil::Serialize::Traits’ ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumes, similarityMaps); ^ /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:11:3: error: ‘TraitType’ does not name a type ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumes, similarityMaps); ^ /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:11:3: error: ‘json::ThorsAnvil::Serialize::TraitType’ has not been declared ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumes, similarityMaps); ^ /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp: In member function ‘void json::JSONHandler::saveJSON(RunInformation)’: /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:14:34: error: ‘json::ThorsAnvil::Serialize::jsonExport’ has not been declared using ThorsAnvil::Serialize::jsonExport; ^~~~~~~~~~ /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:15:34: error: ‘json::ThorsAnvil::Serialize::PrinterInterface’ has not been declared using ThorsAnvil::Serialize::PrinterInterface; ^~~~~~~~~~~~~~~~ /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:17:35: error: ‘jsonExport’ was not declared in this scope std::cout << jsonExport(object); ^ /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:17:35: note: suggested alternative: In file included from /home/mimre/workspace/isosurfaces/json/JSONHandler.h:8:0, from /home/mimre/workspace/isosurfaces/json/JSONHandler.cpp:5: /usr/local/include/ThorSerialize/JsonThor.h:31:19: note: ‘ThorsAnvil::Serialize::jsonExport’ Exporter<Json, T> jsonExport(T const& value, PrinterInterface::OutputType characteristics = PrinterInterface::OutputType::Default) ^~~~~~~~~~ make[3]: *** [CMakeFiles/isosurfaces.dir/json/JSONHandler.cpp.o] Error 1 In file included from /home/mimre/workspace/isosurfaces/Single.cpp:6:0: /home/mimre/workspace/isosurfaces/Single.cpp:24:22: error: ‘volumens’ is not a member of ‘RunInformation’ ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumens, similarityMaps); ^ /home/mimre/workspace/isosurfaces/Single.cpp:24:1: error: template argument 2 is invalid ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumens, similarityMaps); ^ /home/mimre/workspace/isosurfaces/Single.cpp:24:1: error: template argument 3 is invalid ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumens, similarityMaps); ^ /home/mimre/workspace/isosurfaces/Single.cpp:24:1: error: ‘Members’ does not name a type ThorsAnvil_MakeTrait(RunInformation, dimensions, variables, volumens, similarityMaps); ^

Where is the best place to add the MakeTrait call and do I need to add the Traits for all classes, or is it done recursively?

vera++ was installed, but it couldn't find a file during the installation process of Thor. (I don't have the errormsg at hand, but I can recreate it, if needed)

The traits class is defined in: "Traits.h"

If you look at the examples:

Simple Example
Bigger Example

The most important headers to include are:

#include "ThorSerialize/Traits.h"
#include "ThorSerialize/JsonThor.h"   // Change to YamlThor.h for Yaml serialization.

If you need to serialize any standard containers then also include:

#include "ThorSerialize/SerUtil.h"

Note: As mentioned in the Documentation Usage section.

The call to ThorsAnvil_MakeTrait() must be outside all namespace scopes.

Loki

If you have run the ./configure file then the make files should already be using -std=c++14 automatically when you do a build. So that is a bit weird.

Thank you for your help, everything works fine now, I forgot to include "SerUtil.h".

With the -std=c++14 I meant my project.

I can still send you the errors I get during make (after configure ran successfully).