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

Why can't I have std::vector<json&> testList? #2900

Closed
sreerajchundayil opened this issue Jul 30, 2021 · 1 comment
Closed

Why can't I have std::vector<json&> testList? #2900

sreerajchundayil opened this issue Jul 30, 2021 · 1 comment
Labels
solution: invalid the issue is not related to the library

Comments

@sreerajchundayil
Copy link

sreerajchundayil commented Jul 30, 2021

This works.

#include "json.h"
#include <vector>
using json = nlohmann::json;

int main()
{
  std::vector<json> testList;
}

This also works.

#include "json.h"
#include <vector>
using json = nlohmann::json;

int main()
{
  std::vector<json*> testList;
}

This doesn't. Gives compile error. Why?

#include "json.h"
#include <vector>
using json = nlohmann::json;

int main()
{
  std::vector<json&> testList;
}

@sreerajchundayil sreerajchundayil changed the title Why can't I have std::vector<json&> myList? Why can't I have std::vector<json&> testList? Jul 30, 2021
@nlohmann
Copy link
Owner

@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants