MetaStuff icon indicating copy to clipboard operation
MetaStuff copied to clipboard

expected primary-expression before '>' token

Open solomonchild opened this issue 8 years ago • 5 comments

I'm trying to compile w/ this version of g++: g++ (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 5.3.0.

The following error is produced:

C:\dev\misc\MetaStuff\example\JsonCast.inl:98: error: expected primary-expression before '>' token
                         member.set(obj, objName.get<MemberT>());
                                                            ^

solomonchild avatar Sep 28 '17 14:09 solomonchild

Can you try writing objName.template get<MemberT>()?

eliasdaler avatar Sep 28 '17 14:09 eliasdaler

@eliasdaler When I do member.set(obj, objName.template get<MemberT>());, it outputs this:

FAILED: C:\Qt\Tools\mingw530_32\bin\g++.exe   -IC:/dev/misc/MetaStuff/example/nlohmann_json -IC:/dev/misc/MetaStuff/example/../include -std=gnu++14 -MD -MT CMakeFiles/Example.dir/main.cpp.obj -MF CMakeFiles\Example.dir\main.cpp.obj.d -o CMakeFiles/Example.dir/main.cpp.obj -c C:\dev\misc\MetaStuff\example\main.cpp
In file included from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/stl_algobase.h:64:0,

                 from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/char_traits.h:39,

                 from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/ios:40,

                 from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/ostream:38,

                 from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/iostream:39,

                 from C:\dev\misc\MetaStuff\example\main.cpp:1:

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/stl_pair.h: In instantiation of 'constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = std::__cxx11::basic_string<char>; _U2 = const nlohmann::basic_json<>&; <template-parameter-2-3> = void; _T1 = const std::__cxx11::basic_string<char>; _T2 = std::vector<MovieInfo>]':

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/ext/new_allocator.h:120:4:   required from 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> >; _Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>&}; _Tp = std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> >]'

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/alloc_traits.h:256:4:   required from 'static std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> >; _Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>&}; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> > >; std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> = void]'

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/alloc_traits.h:402:16:   required from 'static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> >; _Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>&}; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> > >; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]'

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/hashtable_policy.h:1955:37:   required from 'std::__detail::_Hashtable_alloc<_NodeAlloc>::__node_type* std::__detail::_Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&& ...) [with _Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>&}; _NodeAlloc = std::allocator<std::__detail::_Hash_node<std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> >, true> >; std::__detail::_Hashtable_alloc<_NodeAlloc>::__node_type = std::__detail::_Hash_node<std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> >, true>]'

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/hashtable.h:1526:77:   required from 'std::pair<typename std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _H1, _H2, _Hash, _Traits>::iterator, bool> std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::_M_emplace(std::true_type, _Args&& ...) [with _Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long int, long long unsigned int, double, std::allocator, nlohmann::adl_serializer>&}; _Key = std::__cxx11::basic_string<char>; _Value = std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> > >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::__cxx11::basic_string<char> >; _H1 = std::hash<std::__cxx11::basic_string<char> >; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>; typename std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _H1, _H2, _Hash, _Traits>::iterator = std::__detail::_Node_iterator<std::pair<const std::__cxx11::basic_string<char>, std::vector<MovieInfo> >, false, true>; std::true_type = std::integral_constant<bool, true>]'

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/hashtable.h:726:21:   [ skipping 16 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]

C:\dev\misc\MetaStuff\example\JsonCast.inl:12:22:   required from 'void from_json(const json&, T&) [with T = Person; json = nlohmann::basic_json<>]'

C:/dev/misc/MetaStuff/example/nlohmann_json/json.hpp:1290:25:   required from 'decltype ((nlohmann::detail::from_json(j, val), void())) nlohmann::detail::from_json_fn::call(const BasicJsonType&, T&, nlohmann::detail::priority_tag<1u>) const [with BasicJsonType = nlohmann::basic_json<>; T = Person; decltype ((nlohmann::detail::from_json(j, val), void())) = void]'

C:/dev/misc/MetaStuff/example/nlohmann_json/json.hpp:1305:47:   required from 'void nlohmann::detail::from_json_fn::operator()(const BasicJsonType&, T&) const [with BasicJsonType = nlohmann::basic_json<>; T = Person]'

C:/dev/misc/MetaStuff/example/nlohmann_json/json.hpp:6822:30:   required from 'static void nlohmann::adl_serializer< <template-parameter-1-1>, <template-parameter-1-2> >::from_json(BasicJsonType&&, ValueType&) [with BasicJsonType = const nlohmann::basic_json<>&; ValueType = Person; <template-parameter-1-1> = Person; <template-parameter-1-2> = void]'

C:/dev/misc/MetaStuff/example/nlohmann_json/json.hpp:9461:45:   required from 'ValueType nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get() const [with ValueTypeCV = Person; ValueType = Person; typename std::enable_if<(((! std::is_same<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>, ValueType>::value) && nlohmann::detail::has_from_json<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>, ValueType>::value) && (! nlohmann::detail::has_non_default_from_json<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>, ValueType>::value)), int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]'

C:\dev\misc\MetaStuff\example\main.cpp:88:37:   required from here

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/stl_pair.h:145:64: error: call of overloaded 'vector(const nlohmann::basic_json<>&)' is ambiguous

  : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { }

                                                                ^

In file included from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/vector:64:0,

                 from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/random.h:34,

                 from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/random:49,

                 from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/stl_algo.h:66,

                 from C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/algorithm:62,

                 from C:/dev/misc/MetaStuff/example/nlohmann_json/json.hpp:32,

                 from C:\dev\misc\MetaStuff\example\main.cpp:3:

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/stl_vector.h:373:7: note: candidate: std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = MovieInfo; _Alloc = std::allocator<MovieInfo>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<MovieInfo>]

       vector(initializer_list<value_type> __l,

       ^

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/stl_vector.h:335:7: note: candidate: std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = MovieInfo; _Alloc = std::allocator<MovieInfo>]

       vector(vector&& __x) noexcept

       ^

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/stl_vector.h:318:7: note: candidate: std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = MovieInfo; _Alloc = std::allocator<MovieInfo>]

       vector(const vector& __x)

       ^

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/stl_vector.h:277:7: note: candidate: std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = MovieInfo; _Alloc = std::allocator<MovieInfo>; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<MovieInfo>]

       vector(size_type __n, const allocator_type& __a = allocator_type())

       ^

C:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/bits/stl_vector.h:264:7: note: candidate: std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = MovieInfo; _Alloc = std::allocator<MovieInfo>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<MovieInfo>]

       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT

       ^

ninja: build stopped: subcommand failed.
17:25:33: The process "C:\CMake\bin\cmake.exe" exited with code 1.
Error while building/deploying project Example (kit: Desktop Qt 5.8.0 MinGW 32bit)
When executing step "CMake Build"

solomonchild avatar Sep 28 '17 14:09 solomonchild

Huh, that's a complex error, I'll take a closer look at it soon.

eliasdaler avatar Sep 28 '17 14:09 eliasdaler

On g++ 4.8.5 your suggestion with the inserted template above fixed it for me.

aggsol avatar Mar 13 '18 10:03 aggsol

Cool, maybe it's worth it to make a commit with all template function calls fixed... I kinda hate that this is needed to be done :D

eliasdaler avatar Mar 13 '18 21:03 eliasdaler