Skip to content

expansion pattern 'CompatibleObjectType' contains no argument packs, with CUDA 10 #1347

@carlosgalvezp

Description

@carlosgalvezp

Hi,

I'm using your JSON library in my code. I have a pretty old version (2.1) and would like to upgrade to 3.4.0. However the CUDA 10 compiler seems to have errors when trying to get data as a vectors. With the GCC compiler (5.4) it compiles fine.
I attach example code from this issue, where the issue was solved:

#include <iostream>

#include "json.hpp"

using nlohmann::json;

int main()
{
    auto j = R"(
    {
         "names": ["Tim", "Tom"],
         "num": [1.2, 2.3]
    }
    )"_json;

    std::vector<std::string> names = j["names"];

    for (auto i : names)
    {
        std::cout << i << " ";
    }

    // prints: Tim Tom 
}

This gives the following compilation errors:

$ nvcc -isystem include -std=c++14 main.cu 

include/json.hpp:552:151: error: expansion pattern 'CompatibleObjectType' contains no argument packs
include/json.hpp:552:154: error: template argument 4 is invalid
include/json.hpp:552:261: error: template argument 1 is invalid
include/json.hpp:552:263: error: template argument 3 is invalid
include/json.hpp:577:160: error: expansion pattern 'ConstructibleObjectType' contains no argument packs
include/json.hpp:577:163: error: template argument 4 is invalid
include/json.hpp:577:273: error: template argument 1 is invalid
include/json.hpp:577:275: error: template argument 3 is invalid
include/json.hpp:637:147: error: expansion pattern 'CompatibleArrayType' contains no argument packs
include/json.hpp:637:150: error: template argument 4 is invalid
include/json.hpp:637:335: error: template argument 1 is invalid
include/json.hpp:637:337: error: template argument 3 is invalid
include/json.hpp:667:244: error: expansion pattern 'ConstructibleArrayType' contains no argument packs
include/json.hpp:667:247: error: template argument 4 is invalid
include/json.hpp:667:81: error: parse error in template argument list
main.cu: In function 'int main()':
main.cu:16:118: error: conversion from 'nlohmann::basic_json<>::value_type {aka nlohmann::basic_json<>}' to non-scalar type 'std::vector<std::__cxx11::basic_string<char> >' requested

Using the get<std::vector<std::string>> method gives even more errors on top of the previous ones.

Have you seen this error before?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: help neededthe issue needs help to proceedstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions