I have a template function in C++, meant for converting a rapidjson::GenericArray into an std::array:
namespace jsonutils
{
template <typename T, int size>
inline std::array<T, size> toArray(
const rapidjson::GenericArray<false, rapidjson::Value>* value
)
{
std::array<T, size> result;
for (rapidjson::SizeType i = 0; i < value.Size(); i++)
{
result[i] = value[i];
}
return result;
}
}
However, when I try the following:
const rapidjson::GenericArray<false, rapidjson::Value>* bNode =
&node["b"].GetArray();
int size = bNode->Size();
std::array<int, 3> b = jsonutils::toArray<int, size>(bNode);
I get the following errors:
- E0304: no instance of function template "
jsonutils::toArray" matches the argument list- Argument types are: (
const rapidjson::GenericArray<false, rapidjson::Value>)
- Argument types are: (
- C2672: '
jsonutils::toArray': no matching overloaded function found
When I hover over jsonutils::toArray in Visual Studio, it lists the template as template<class T, int size>.
Why does this call not work?