Skip to content

json_fwd.hpp doesn't work #3796

Description

@Derpalus

Description

json_fwd.hpp no longer works. When using it in a header there is an "incomplete class" error in the corresponding code file.

I have already figured out why this happens: The basic_json template differs between json_fwd.hpp and json.hpp. In json_fwd.hpp there is a class CustomBaseClass = void at the end which is not there in json.hpp (line 151 in json_fwd.hpp). When I manually remove that line in my project it works fine.

Reproduction steps

Just #include <nlohmann/json_fwd.hpp> in a header and try to use it in the code file.

Expected vs. actual results

Expected: Should work to use json_fwd.hpp to forward-declare nlohmann::json.
Actual: Does not work to forward-declare using json_fwd.hpp; results in "incomplete class" error in code file when trying to use it.

Minimal code example

No response

Error messages

error C2976: 'nlohmann::json_abi_v3_11_2::basic_json': too few template arguments
error C3203: 'basic_json': unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type

Compiler and operating system

Windows, Microsoft Visual C++ 2019

Library version

3.11.2

Validation

Activity

  1. gregmarr commented on Oct 17, 2022

    @gregmarr
    Contributor

    Looks like you somehow have mismatched headers, as this was added in macro_scope.hpp and json_fwd.hpp in #3110 .

  2. Derpalus commented on Oct 17, 2022

    @Derpalus
    Author

    Ah, my bad, I downloaded the 3.11.2 release of json.hpp but the latest develop for json_fwd.hpp. Nothing wrong here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions