I’m changing a generation template of OpenAPI generator to help solving an issue affecting one user.
I’m stumbling upon what its generation causes:
A parameterToString(...)
method offers many prototypes, and is used without troubles when its argument has a primitive type.
But it causes a compilation error for its templated const std::shared_ptr<T>& value
or const boost::optional<const std::shared_ptr<T>>& value
ones:
The method is declared in the ApiClient.h
file generated:
* This is an API client responsible for stating the HTTP calls
static utility::string_t parameterToString(utility::string_t value);
static utility::string_t parameterToString(int32_t value);
static utility::string_t parameterToString(int64_t value);
static utility::string_t parameterToString(float value);
static utility::string_t parameterToString(double value);
static utility::string_t parameterToString(const utility::datetime &value);
static utility::string_t parameterToString(bool value);
static utility::string_t parameterToString(const std::vector<T>& value);
utility::string_t parameterToString(const boost::optional<const std::shared_ptr<T>>& value);
utility::string_t parameterToString(const boost::optional<T>& value);
static utility::string_t parameterToString(const std::shared_ptr<T>& value);
utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
utility::stringstream_t ss;
for( size_t i = 0; i < value.size(); i++)
if( i > 0) ss << utility::conversions::to_string_t(", ");
ss << ApiClient::parameterToString(value[i]);
utility::string_t ApiClient::parameterToString(const boost::optional<T>& value)
return parameterToString(*value.get());
return "** nullptr (A) **";
utility::string_t ApiClient::parameterToString(const boost::optional<const std::shared_ptr<T>>& value)
return parameterToString(*value.get());
return "** nullptr (B) **";
utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
return parameterToString(*value.get());
<code>/*
* ApiClient.h
* This is an API client responsible for stating the HTTP calls
*/
// [...]
class ApiClient
{
public:
// [...]
static utility::string_t parameterToString(utility::string_t value);
static utility::string_t parameterToString(int32_t value);
static utility::string_t parameterToString(int64_t value);
static utility::string_t parameterToString(float value);
static utility::string_t parameterToString(double value);
static utility::string_t parameterToString(const utility::datetime &value);
static utility::string_t parameterToString(bool value);
template<class T>
static utility::string_t parameterToString(const std::vector<T>& value);
template<class T>
utility::string_t parameterToString(const boost::optional<const std::shared_ptr<T>>& value);
template<class T>
utility::string_t parameterToString(const boost::optional<T>& value);
template<class T>
static utility::string_t parameterToString(const std::shared_ptr<T>& value);
// [...]
};
template<class T>
utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
{
utility::stringstream_t ss;
for( size_t i = 0; i < value.size(); i++)
{
if( i > 0) ss << utility::conversions::to_string_t(", ");
ss << ApiClient::parameterToString(value[i]);
}
return ss.str();
}
template<class T>
utility::string_t ApiClient::parameterToString(const boost::optional<T>& value)
{
if (value.has_value()) {
return parameterToString(*value.get());
}
else {
return "** nullptr (A) **";
}
}
template<class T>
utility::string_t ApiClient::parameterToString(const boost::optional<const std::shared_ptr<T>>& value)
{
if (value.has_value()) {
return parameterToString(*value.get());
}
else {
return "** nullptr (B) **";
}
}
template<class T>
utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
{
return parameterToString(*value.get());
}
}
</code>
/*
* ApiClient.h
* This is an API client responsible for stating the HTTP calls
*/
// [...]
class ApiClient
{
public:
// [...]
static utility::string_t parameterToString(utility::string_t value);
static utility::string_t parameterToString(int32_t value);
static utility::string_t parameterToString(int64_t value);
static utility::string_t parameterToString(float value);
static utility::string_t parameterToString(double value);
static utility::string_t parameterToString(const utility::datetime &value);
static utility::string_t parameterToString(bool value);
template<class T>
static utility::string_t parameterToString(const std::vector<T>& value);
template<class T>
utility::string_t parameterToString(const boost::optional<const std::shared_ptr<T>>& value);
template<class T>
utility::string_t parameterToString(const boost::optional<T>& value);
template<class T>
static utility::string_t parameterToString(const std::shared_ptr<T>& value);
// [...]
};
template<class T>
utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
{
utility::stringstream_t ss;
for( size_t i = 0; i < value.size(); i++)
{
if( i > 0) ss << utility::conversions::to_string_t(", ");
ss << ApiClient::parameterToString(value[i]);
}
return ss.str();
}
template<class T>
utility::string_t ApiClient::parameterToString(const boost::optional<T>& value)
{
if (value.has_value()) {
return parameterToString(*value.get());
}
else {
return "** nullptr (A) **";
}
}
template<class T>
utility::string_t ApiClient::parameterToString(const boost::optional<const std::shared_ptr<T>>& value)
{
if (value.has_value()) {
return parameterToString(*value.get());
}
else {
return "** nullptr (B) **";
}
}
template<class T>
utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
{
return parameterToString(*value.get());
}
}
And its attempt to be used fails here, for example:
<code>pplx::task<std::shared_ptr<VideoChapters>> VideoChaptersApi::getVideoChapters(
std::shared_ptr<_api_v1_videos_ownership__id__accept_post_id_parameter> id,
boost::optional<utility::string_t> xPeertubeVideoPassword) const
boost::replace_all(localVarPath,
utility::conversions::to_string_t("{") + utility::conversions::to_string_t("id") +
utility::conversions::to_string_t("}"),
web::uri::encode_uri(ApiClient::parameterToString(id)));
<code>pplx::task<std::shared_ptr<VideoChapters>> VideoChaptersApi::getVideoChapters(
std::shared_ptr<_api_v1_videos_ownership__id__accept_post_id_parameter> id,
boost::optional<utility::string_t> xPeertubeVideoPassword) const
{
// [...]
boost::replace_all(localVarPath,
utility::conversions::to_string_t("{") + utility::conversions::to_string_t("id") +
utility::conversions::to_string_t("}"),
web::uri::encode_uri(ApiClient::parameterToString(id)));
// [...]
}
</code>
pplx::task<std::shared_ptr<VideoChapters>> VideoChaptersApi::getVideoChapters(
std::shared_ptr<_api_v1_videos_ownership__id__accept_post_id_parameter> id,
boost::optional<utility::string_t> xPeertubeVideoPassword) const
{
// [...]
boost::replace_all(localVarPath,
utility::conversions::to_string_t("{") + utility::conversions::to_string_t("id") +
utility::conversions::to_string_t("}"),
web::uri::encode_uri(ApiClient::parameterToString(id)));
// [...]
}
where _api_v1_videos_ownership__id__accept_post_id_parameter
is a class that has nothing special. it fails with the messages:
<code>ApiClient.h: In instantiation of
‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::shared_ptr<_Tp>&)
[with T = org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter; utility::string_t = std::__cxx11::basic_string<char>]’:
LiveVideosApi.cpp:245:210: required from here
ApiClient.h:105:29: error: no matching function for call to ‘org::openapitools::client::api::ApiClient::parameterToString(std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type&)’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ApiClient.h:89:19: note: candidate: ‘template<class T> static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::vector<_Type>&)’
89 | utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
ApiClient.h:89:19: note: template argument deduction/substitution failed:
ApiClient.h:105:29: note: ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} is not derived from ‘const std::vector<_Type>’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ApiClient.h:103:19: note: candidate: ‘template<class T> static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::shared_ptr<_Tp>&)’
103 | utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
ApiClient.h:103:19: note: template argument deduction/substitution failed:
ApiClient.h:105:29: note: ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} is not derived from ‘const std::shared_ptr<_Tp>’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ApiClient.h:59:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(utility::string_t)’
59 | static utility::string_t parameterToString(utility::string_t value);
ApiClient.h:59:66: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘utility::string_t’ {aka ‘std::__cxx11::basic_string<char>’}
59 | static utility::string_t parameterToString(utility::string_t value);
| ~~~~~~~~~~~~~~~~~~^~~~~
ApiClient.h:60:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(int32_t)’
60 | static utility::string_t parameterToString(int32_t value);
ApiClient.h:60:56: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘int32_t’ {aka ‘int’}
60 | static utility::string_t parameterToString(int32_t value);
ApiClient.h:61:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(int64_t)’
61 | static utility::string_t parameterToString(int64_t value);
ApiClient.h:61:56: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘int64_t’ {aka ‘long int’}
61 | static utility::string_t parameterToString(int64_t value);
ApiClient.h:62:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(float)’
62 | static utility::string_t parameterToString(float value);
ApiClient.h:62:54: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘float’
62 | static utility::string_t parameterToString(float value);
ApiClient.h:63:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(double)’
63 | static utility::string_t parameterToString(double value);
ApiClient.h:63:55: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘double’
63 | static utility::string_t parameterToString(double value);
ApiClient.h:64:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const utility::datetime&)’
64 | static utility::string_t parameterToString(const utility::datetime &value);
ApiClient.h:64:73: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘const utility::datetime&’
64 | static utility::string_t parameterToString(const utility::datetime &value);
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
ApiClient.h:65:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(bool)’
65 | static utility::string_t parameterToString(bool value);
ApiClient.h:65:53: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘bool’
65 | static utility::string_t parameterToString(bool value);
<code>ApiClient.h: In instantiation of
‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::shared_ptr<_Tp>&)
[with T = org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter; utility::string_t = std::__cxx11::basic_string<char>]’:
LiveVideosApi.cpp:245:210: required from here
ApiClient.h:105:29: error: no matching function for call to ‘org::openapitools::client::api::ApiClient::parameterToString(std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type&)’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ApiClient.h:89:19: note: candidate: ‘template<class T> static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::vector<_Type>&)’
89 | utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
| ^~~~~~~~~
ApiClient.h:89:19: note: template argument deduction/substitution failed:
ApiClient.h:105:29: note: ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} is not derived from ‘const std::vector<_Type>’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ApiClient.h:103:19: note: candidate: ‘template<class T> static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::shared_ptr<_Tp>&)’
103 | utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
| ^~~~~~~~~
ApiClient.h:103:19: note: template argument deduction/substitution failed:
ApiClient.h:105:29: note: ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} is not derived from ‘const std::shared_ptr<_Tp>’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ApiClient.h:59:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(utility::string_t)’
59 | static utility::string_t parameterToString(utility::string_t value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:59:66: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘utility::string_t’ {aka ‘std::__cxx11::basic_string<char>’}
59 | static utility::string_t parameterToString(utility::string_t value);
| ~~~~~~~~~~~~~~~~~~^~~~~
ApiClient.h:60:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(int32_t)’
60 | static utility::string_t parameterToString(int32_t value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:60:56: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘int32_t’ {aka ‘int’}
60 | static utility::string_t parameterToString(int32_t value);
| ~~~~~~~~^~~~~
ApiClient.h:61:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(int64_t)’
61 | static utility::string_t parameterToString(int64_t value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:61:56: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘int64_t’ {aka ‘long int’}
61 | static utility::string_t parameterToString(int64_t value);
| ~~~~~~~~^~~~~
ApiClient.h:62:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(float)’
62 | static utility::string_t parameterToString(float value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:62:54: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘float’
62 | static utility::string_t parameterToString(float value);
| ~~~~~~^~~~~
ApiClient.h:63:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(double)’
63 | static utility::string_t parameterToString(double value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:63:55: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘double’
63 | static utility::string_t parameterToString(double value);
| ~~~~~~~^~~~~
ApiClient.h:64:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const utility::datetime&)’
64 | static utility::string_t parameterToString(const utility::datetime &value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:64:73: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘const utility::datetime&’
64 | static utility::string_t parameterToString(const utility::datetime &value);
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
ApiClient.h:65:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(bool)’
65 | static utility::string_t parameterToString(bool value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:65:53: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘bool’
65 | static utility::string_t parameterToString(bool value);
| ~~~~~^~~~~
</code>
ApiClient.h: In instantiation of
‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::shared_ptr<_Tp>&)
[with T = org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter; utility::string_t = std::__cxx11::basic_string<char>]’:
LiveVideosApi.cpp:245:210: required from here
ApiClient.h:105:29: error: no matching function for call to ‘org::openapitools::client::api::ApiClient::parameterToString(std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type&)’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ApiClient.h:89:19: note: candidate: ‘template<class T> static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::vector<_Type>&)’
89 | utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
| ^~~~~~~~~
ApiClient.h:89:19: note: template argument deduction/substitution failed:
ApiClient.h:105:29: note: ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} is not derived from ‘const std::vector<_Type>’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ApiClient.h:103:19: note: candidate: ‘template<class T> static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::shared_ptr<_Tp>&)’
103 | utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
| ^~~~~~~~~
ApiClient.h:103:19: note: template argument deduction/substitution failed:
ApiClient.h:105:29: note: ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} is not derived from ‘const std::shared_ptr<_Tp>’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
ApiClient.h:59:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(utility::string_t)’
59 | static utility::string_t parameterToString(utility::string_t value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:59:66: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘utility::string_t’ {aka ‘std::__cxx11::basic_string<char>’}
59 | static utility::string_t parameterToString(utility::string_t value);
| ~~~~~~~~~~~~~~~~~~^~~~~
ApiClient.h:60:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(int32_t)’
60 | static utility::string_t parameterToString(int32_t value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:60:56: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘int32_t’ {aka ‘int’}
60 | static utility::string_t parameterToString(int32_t value);
| ~~~~~~~~^~~~~
ApiClient.h:61:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(int64_t)’
61 | static utility::string_t parameterToString(int64_t value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:61:56: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘int64_t’ {aka ‘long int’}
61 | static utility::string_t parameterToString(int64_t value);
| ~~~~~~~~^~~~~
ApiClient.h:62:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(float)’
62 | static utility::string_t parameterToString(float value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:62:54: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘float’
62 | static utility::string_t parameterToString(float value);
| ~~~~~~^~~~~
ApiClient.h:63:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(double)’
63 | static utility::string_t parameterToString(double value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:63:55: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘double’
63 | static utility::string_t parameterToString(double value);
| ~~~~~~~^~~~~
ApiClient.h:64:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const utility::datetime&)’
64 | static utility::string_t parameterToString(const utility::datetime &value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:64:73: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘const utility::datetime&’
64 | static utility::string_t parameterToString(const utility::datetime &value);
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
ApiClient.h:65:30: note: candidate: ‘static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(bool)’
65 | static utility::string_t parameterToString(bool value);
| ^~~~~~~~~~~~~~~~~
ApiClient.h:65:53: note: no known conversion for argument 1 from ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} to ‘bool’
65 | static utility::string_t parameterToString(bool value);
| ~~~~~^~~~~
I don’t understand how to handle this refusal:
<code>ApiClient.h:103:19: note: candidate: ‘template<class T> static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::shared_ptr<_Tp>&)’
103 | utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
ApiClient.h:103:19: note: template argument deduction/substitution failed:
ApiClient.h:105:29: note: ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} is not derived from ‘const std::shared_ptr<_Tp>’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
<code>ApiClient.h:103:19: note: candidate: ‘template<class T> static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::shared_ptr<_Tp>&)’
103 | utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
| ^~~~~~~~~
ApiClient.h:103:19: note: template argument deduction/substitution failed:
ApiClient.h:105:29: note: ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} is not derived from ‘const std::shared_ptr<_Tp>’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
</code>
ApiClient.h:103:19: note: candidate: ‘template<class T> static utility::string_t org::openapitools::client::api::ApiClient::parameterToString(const std::shared_ptr<_Tp>&)’
103 | utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
| ^~~~~~~~~
ApiClient.h:103:19: note: template argument deduction/substitution failed:
ApiClient.h:105:29: note: ‘std::__shared_ptr<org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter, __gnu_cxx::_S_atomic>::element_type’ {aka ‘org::openapitools::client::model::_api_v1_videos_ownership__id__accept_post_id_parameter’} is not derived from ‘const std::shared_ptr<_Tp>’
105 | return parameterToString(*value.get());
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
According to the message I’m reading, I should have an additional prototype available?
static utility::string_t parameterToString(const T& value);
<code>template<class T>
static utility::string_t parameterToString(const T& value);
</code>
template<class T>
static utility::string_t parameterToString(const T& value);
?
But it looks to me dangerous to declare such one, as some cases, like boost::optional<...>
parameters requires a special handling (just started here):
utility::string_t ApiClient::parameterToString(const boost::optional<const std::shared_ptr<T>>& value)
return parameterToString(*value.get());
return "** nullptr (B) **";
<code>template<class T>
utility::string_t ApiClient::parameterToString(const boost::optional<const std::shared_ptr<T>>& value)
{
if (value.has_value()) {
return parameterToString(*value.get());
}
else {
return "** nullptr (B) **";
}
}
</code>
template<class T>
utility::string_t ApiClient::parameterToString(const boost::optional<const std::shared_ptr<T>>& value)
{
if (value.has_value()) {
return parameterToString(*value.get());
}
else {
return "** nullptr (B) **";
}
}
So, I don’t think it could/should be summarized in a “T&
only” method.
How should I correct the template defined in ApiClient.h
so that parameters of kind const std::shared_ptr<T>& value
or const boost::optional<const std::shared_ptr<T>>& value
will be accepted?
Thanks!