Skip to content

Weird template issue in large project #1162

Closed

Description

@JasonDictos

So I've been integrating this amazing json library into a closed source project for some time, recently when I started using std::variant a bit, things started to go south on gcc 8.1.0. The same code compiles and works fine on visual studio 2017 (latest as of this writing).

The basic idea is I have a variant with various structures defined in it, each with their own overload for to_json/from_json calls.

When I try to use std::get<structure_name>(variant_member) I get an error:

error: exception specification of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::basic_json(CompatibleType&&) [with CompatibleType = const signalwire::client::blade::Netcast::RouteRemove&; U = signalwire::client::blade::Netcast::RouteRemove; typename std::enable_if<nlohmann::detail::is_compatible_type<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>, U>::value, int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’ depends on itself

Note other uses with std::variant have worked in the past on same compiler/platform.

Activity

  1. JasonDictos commented on Jul 14, 2018

    @JasonDictos
    Author

    Ah, figured it out. I was using an alias for my variant type, then I was specializing the to_json with that definition. By removing that specialization, all is well.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions