Skip to content

template parameter "T" is not used in declaring the parameter types of function template #386

@MedicineYeh

Description

@MedicineYeh

Hello,
I tried different compilers with this super great repo. Both GCC and Clang can compile it without any warning and error. However, due to some unknown issue, Intel ICC seems to implement this template declaration check differently.
Here is the warning message I got when I compile with the icpc (ICC) 16.0.3 20160415.

In file included from ./json.cc(1):
./json.hpp(1335): warning #488: template parameter "T" is not used in declaring the parameter types of function template "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json<T,<unnamed>>(NumberIntegerType)"
      template<typename T, typename std::enable_if<
                        ^

In file included from ./json.cc(1):
./json.hpp(1430): warning #488: template parameter "T" is not used in declaring the parameter types of function template "nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json<T,<unnamed>>(NumberUnsignedType)"
      template<typename T, typename std::enable_if<

I found a way to walk around it, which is using the template type instead of using the specific type on line 1338 and 1433.
Here is my walk around (I only change number_integer_t to T):

 1335     template<typename T, typename std::enable_if<
 1336                  not (std::is_same<T, int>::value) and
 1337                  std::is_same<T, number_integer_t>::value, int>::type = 0>
 1338     basic_json(const T val) noexcept
 1339         : m_type(value_t::number_integer), m_value(val)
 1340     {
 1341         assert_invariant();
 1342     }

Line 1433 is the same thing.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions