Skip to content

Empty tuple conversion fails to compile #1196

Open

Description

@jrade

Automatic conversion between std::tuple<> and boost::json::value does not work.
The code

std::tuple<> t0;
boost::json::value v = boost::json::value_from(t0);
std::tuple<> t1 = boost::json::value_to<std::tuple<>>(v);

fails to compile with the error message

static assertion failed: 'No suitable tag_invoke overload found for the type'.

This seems counterintuitive. Obviously an empty C++ tuple should be converted to an empty JSON array and vice-versa.

Tested with Boost 1.92.0 and Visual Studio 2026 on Windows 11.

Activity

  1. grisumbras commented on Sep 9, 2026

    @grisumbras
    Member

    Yes, see this section:

    ... if std::tuple_size<T>::value is a positive number.

    I currently don't remember the specific type which was incorrectly categorised as a tuple if I did not check for positve size, but there was something.

    What's your use case for empty tuples?

  2. jrade commented on Sep 9, 2026

    @jrade
    Author

    No use case at all. I was just playing around with the library to learn how it works. It is rather a matter of logical consistency.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions