You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
template parameter "T" is not used in declaring the parameter types of function template #386
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):
Hey @MedicineYeh, thanks for the report. I don't exactly remember why I had to add T in this indirect style, but there is a comment:
@tparam T A helper type to remove this function via SFINAE in case @ref
number_integer_t is the same as `int`. In this case, this constructor
would have the same signature as @ref basic_json(const int value). Note
the helper type @a T is not visible in this constructor's interface.
It may be possible to change the code, but I think that this may break the code on MSVC or any other compiler which made me code it this way in the first place.
Hi @nlohmann@gregmarr ,
Thanks for your replies. I think using T should be safe to any compiler since it's basically the same thing of written number_integer since you have a type checking on the constructor. It depends on whether you want to make this function a real template function or a function with template type check. I usually prefer the later since it's more clear on types. However, the chain constructor tells the types already, so it doesn't really matter to me.
I don't have a MSVC compiler. It's worthy to try if there's any problem. Thanks.
Cool, so this work around do make some ambiguity... Seems like my work around is not a good way to fix the warning. Still, the warning is not harmful so I would like to conclude with don't change the type. I have no better idea on fixing this warning. I would consider to send a report to Intel so that they might fix this in the future version. It's really non sense of reporting warning on this peice of code.
By the way, my Linux compiler versions are (GCC) 6.2.1 20160830 and clang version 3.9.0.
Activity
nlohmann commentedon Dec 8, 2016
Hey @MedicineYeh, thanks for the report. I don't exactly remember why I had to add
Tin this indirect style, but there is a comment:It may be possible to change the code, but I think that this may break the code on MSVC or any other compiler which made me code it this way in the first place.
gregmarr commentedon Dec 8, 2016
@nlohmann I think changing
number_integer_ttoTin the function parameter list should be a safe change.MedicineYeh commentedon Dec 9, 2016
Hi @nlohmann @gregmarr ,
Thanks for your replies. I think using
Tshould be safe to any compiler since it's basically the same thing of writtennumber_integersince you have a type checking on the constructor. It depends on whether you want to make this function a real template function or a function with template type check. I usually prefer the later since it's more clear on types. However, the chain constructor tells the types already, so it doesn't really matter to me.I don't have a MSVC compiler. It's worthy to try if there's any problem. Thanks.
nlohmann commentedon Dec 9, 2016
When I make this change
I get this compiler error:
Tried with Apple LLVM version 8.0.0 (clang-800.0.42.1) and g++-6 (Homebrew gcc 6.2.0) 6.2.0.
MedicineYeh commentedon Dec 10, 2016
Cool, so this work around do make some ambiguity... Seems like my work around is not a good way to fix the warning. Still, the warning is not harmful so I would like to conclude with don't change the type. I have no better idea on fixing this warning. I would consider to send a report to Intel so that they might fix this in the future version. It's really non sense of reporting warning on this peice of code.
By the way, my Linux compiler versions are (GCC) 6.2.1 20160830 and clang version 3.9.0.
nlohmann commentedon Dec 10, 2016
I think we can close this issue, right?
TurpentineDistillery commentedon Dec 13, 2016
To follow-up,
ICC has
#pragma warning disablefacilities, so this can be silenced in compiler-specific manner.MedicineYeh commentedon Dec 13, 2016
Cool. Thanks everyone.
owlas commentedon Jan 26, 2017
@TurpentineDistillery also possible on the command line with
-wd488icc docs