Skip to content
New issue

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

Error when using json in g++ #254

Closed
maciek-slon opened this issue May 28, 2016 · 1 comment
Closed

Error when using json in g++ #254

maciek-slon opened this issue May 28, 2016 · 1 comment

Comments

@maciek-slon
Copy link

When trying to compile simple program using devel branch:

#include "json.hpp"

// for convenience
using json = nlohmann::json;

int main() {
    // create an empty structure (null)
    json j;

    // add a number that is stored as double (note the implicit conversion of j to an object)
    j["pi"] = 3.141;

    return 0;
}

following error is produced:

In file included from test.cpp:1:0:
json.hpp: In constructor ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json() [with 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]’:
json.hpp:1060:5: error: conversion from ‘nlohmann::basic_json<>::value_t’ to non-scalar type ‘nlohmann::basic_json<>::type_data_t’ requested
     basic_json() = default;
     ^
test.cpp: In function ‘int main()’:
test.cpp:8:10: note: synthesized method ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json() [with 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]’ first required here 
     json j;
          ^

Compiler version:

g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

Compile command:

g++ test.cpp -std=c++11
@maciek-slon
Copy link
Author

NVM. Missed info about not working in 4.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant