We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
failed to compile
code:
#include "json.hpp" struct RealmList { int32_t person_abilitiy; std::vector<std::vector<int32_t>> consumeitem; std::vector<std::vector<int32_t>> attr; }; struct QtRealm { int32_t open_level; std::vector<RealmList> realm_list; }; namespace nlohmann { namespace detail { void from_json(const json & j, RealmList & x); void from_json(const json & j, QtRealm & x); inline void from_json(const json & j, RealmList& x) { x.person_abilitiy = j.at("person_abilitiy").get<int32_t>(); x.consumeitem = j.at("consumeitem").get<std::vector<std::vector<int32_t>>>(); x.attr = j.at("attr").get<std::vector<std::vector<int32_t>>>(); } inline void from_json(const json & j, QtRealm& x) { x.open_level = j.at("open_level").get<int32_t>(); x.realm_list = j.at("realm_list").get<std::vector<RealmList>>(); } } } int main(int argc, char *argv[]) { return 0; }
result:
root@localhost:/# /usr/bin/g++ main.cpp -O0 -g3 -Wall -Wno-literal-suffix -Wnarrowing -Wno-write-strings -fpermissive -std=c++11 main.cpp: In function ‘void nlohmann::detail::from_json(const json&, QtRealm&)’: main.cpp:27:71: error: no matching function for call to ‘nlohmann::basic_json<>::get() const’ x.realm_list = j.at("realm_list").get<std::vector<RealmList>>(); ^ main.cpp:27:71: note: candidates are: In file included from main.cpp:1:0: json.hpp:14883:16: note: template<class BasicJsonType, typename std::enable_if<std::is_same<typename std::remove_const<_Tp>::type, nlohmann::basic_json<> >::value, int>::type <anonymous> > nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get() const [with BasicJsonType = BasicJsonType; typename std::enable_if<std::is_same<typename std::remove_const<BasicJsonType>::type, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> >::value, int>::type <anonymous> = <enumerator>; ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer] basic_json get() const ^ json.hpp:14883:16: note: template argument deduction/substitution failed: json.hpp:14882:25: error: no type named ‘type’ in ‘struct std::enable_if<false, int>’ int> = 0> ^ json.hpp:14882:25: note: invalid template non-type parameter json.hpp:14906:19: note: template<class BasicJsonType, typename std::enable_if<((! std::is_same<BasicJsonType, nlohmann::basic_json<> >::value) && nlohmann::detail::is_basic_json<BasicJsonType>::value), int>::type <anonymous> > BasicJsonType nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get() const [with BasicJsonType = BasicJsonType; typename std::enable_if<((! std::is_same<BasicJsonType, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> >::value) && nlohmann::detail::is_basic_json<BasicJsonType>::value), int>::type <anonymous> = <enumerator>; ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer] BasicJsonType get() const ^ json.hpp:14906:19: note: template argument deduction/substitution failed: json.hpp:14905:70: error: no type named ‘type’ in ‘struct std::enable_if<false, int>’ detail::is_basic_json<BasicJsonType>::value, int> = 0> ^ json.hpp:14905:70: note: invalid template non-type parameter json.hpp:14956:15: note: template<class ValueTypeCV, class ValueType, typename std::enable_if<(((! nlohmann::detail::is_basic_json<T>::value) && nlohmann::detail::has_from_json<nlohmann::basic_json<>, ValueType, void>::value) && (! nlohmann::detail::has_non_default_from_json<nlohmann::basic_json<>, ValueType, void>::value)), int>::type <anonymous> > ValueType nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get() const [with ValueTypeCV = ValueTypeCV; ValueType = ValueType; typename std::enable_if<(((! nlohmann::detail::is_basic_json<U>::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> = <enumerator>; ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer] ValueType get() const noexcept(noexcept( ^ json.hpp:14956:15: note: template argument deduction/substitution failed: json.hpp:14955:25: error: no type named ‘type’ in ‘struct std::enable_if<false, int>’ int> = 0> ^ json.hpp:14955:25: note: invalid template non-type parameter json.hpp:15007:15: note: template<class ValueTypeCV, class ValueType, typename std::enable_if<((! std::is_same<nlohmann::basic_json<>, ValueType>::value) && nlohmann::detail::has_non_default_from_json<nlohmann::basic_json<>, ValueType, void>::value), int>::type <anonymous> > ValueType nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get() const [with ValueTypeCV = ValueTypeCV; ValueType = ValueType; typename std::enable_if<((! std::is_same<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> = <enumerator>; ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer] ValueType get() const noexcept(noexcept( ^ json.hpp:15007:15: note: template argument deduction/substitution failed: json.hpp:15006:41: error: no type named ‘type’ in ‘struct std::enable_if<false, int>’ int> = 0> ^ json.hpp:15006:41: note: invalid template non-type parameter json.hpp:15137:10: note: template<class PointerType, typename std::enable_if<std::is_pointer<_Tp>::value, int>::type <anonymous> > decltype (declval<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::basic_json_t&>().get_ptr<PointerType>()) nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get() [with PointerType = PointerType; typename std::enable_if<std::is_pointer<_Ptr>::value, int>::type <anonymous> = <enumerator>; ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer] auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>()) ^ json.hpp:15137:10: note: template argument deduction/substitution failed: json.hpp:15136:68: error: no type named ‘type’ in ‘struct std::enable_if<false, int>’ std::is_pointer<PointerType>::value, int>::type = 0> ^ json.hpp:15136:68: note: invalid template non-type parameter json.hpp:15149:20: note: template<class PointerType, typename std::enable_if<std::is_pointer<_Tp>::value, int>::type <anonymous> > constexpr decltype (declval<const basic_json_t&>().get_ptr<PointerType>()) nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get() const [with PointerType = PointerType; typename std::enable_if<std::is_pointer<_Ptr>::value, int>::type <anonymous> = <enumerator>; ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer] constexpr auto get() const noexcept -> decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>()) ^ json.hpp:15149:20: note: template argument deduction/substitution failed: json.hpp:15148:68: error: no type named ‘type’ in ‘struct std::enable_if<false, int>’ std::is_pointer<PointerType>::value, int>::type = 0> ^ json.hpp:15148:68: note: invalid template non-type parameter
What is the expected behavior?
And what is the actual behavior instead?
template argument deduction/substitution failed
Which compiler and operating system are you using? Is it a supported compiler?
Did you use a released version of the library or the version from the develop branch?
develop
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
uname -a Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
From the brance
I have run the unit tests, 100% tests passed, 0 tests failed out of 88.
The text was updated successfully, but these errors were encountered:
Sorry, I miss the document saying that the methods MUST be in my type's namespace. Closed.
Sorry, something went wrong.
@ripwu Thanks for that!
No branches or pull requests
failed to compile
code:
result:
What is the expected behavior?
And what is the actual behavior instead?
template argument deduction/substitution failed
Which compiler and operating system are you using? Is it a supported compiler?
Did you use a released version of the library or the version from the
develop
branch?gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
uname -a
Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
From the brance
I have run the unit tests, 100% tests passed, 0 tests failed out of 88.
The text was updated successfully, but these errors were encountered: