Skip to content

Boolean value in array [is it possible?] #3533

Discussion options

You must be logged in to vote

std::vector<bool>::reference is not a bool & as on might expect (see https://en.cppreference.com/w/cpp/container/vector_bool).

Either of the options below should work.

  for (bool param : std::get<2>(parameters))
  {
    request["params"].push_back(param);
  }

  for (auto param : std::get<2>(parameters))
  {
    request["params"].push_back(static_cast<bool>(param));
  }

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@nlohmann
Comment options

@falbrechtskirchinger
Comment options

@falbrechtskirchinger
Comment options

@nlohmann
Comment options

@kenkit
Comment options

Answer selected by kenkit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants