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

Can't compile from_json(std::valarray<T>). #1824

Closed
ghost opened this issue Nov 4, 2019 · 2 comments
Closed

Can't compile from_json(std::valarray<T>). #1824

ghost opened this issue Nov 4, 2019 · 2 comments
Assignees
Labels
confirmed kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Milestone

Comments

@ghost
Copy link

ghost commented Nov 4, 2019

Following code couldn't be compiled because the from_json implementation uses the private member 'm_value'.

json Version: v3.7.0

#include <nlohmann/json.hpp>

using json = nlohmann::json;

int main()
{
   json j = json::array({1, 0, 2});
   j.get<std::valarray<int>>();
}

https://wandbox.org/permlink/ifYduziYXUtfgP4n

@ghost ghost added the kind: bug label Nov 4, 2019
@nlohmann
Copy link
Owner

nlohmann commented Nov 4, 2019

Indeed. Changing

std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l));

to

std::copy(j.begin(), j.end(), std::begin(l));

fixes the issue.

@nlohmann nlohmann self-assigned this Nov 5, 2019
@nlohmann nlohmann added release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation labels Nov 5, 2019
@nlohmann nlohmann added this to the Release 3.7.1 milestone Nov 5, 2019
@nlohmann
Copy link
Owner

nlohmann commented Nov 5, 2019


🔖 Release item

This issue/PR will be part of the next release of the library. This template helps preparing the release notes.

Type

  • ✨ New Feature
  • 🐛 Bug Fix
  • ⚡️ Improvement
  • 🔨 Further Change
  • 🔥 Deprecated function

Description

  • fix conversion to std::valarray

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

1 participant