How to add a 'convert' member function to create a RPC that returns std::tuple<int, std::string>?

18 views
Skip to first unread message

nico....@gmail.com

unread,
Jun 29, 2016, 10:50:43 AM6/29/16
to CppWAMP
Hello, 

I would like to create a remote procedure call to a function that returns a "std::tuple<int, std::string>", but when I try this I get an error stating that:
"The 'convert' function has not been specialized for this type. Either provide a 'convert' free function specialization, or a 'convert' member function." originating from cppwamp/internal/conversion.ipp line 246.

I can imagine that it is impossible to pre-define functions to to convert any return type to something that can be processed and I think it is great that the most common types are already supported, but now I would like to know what I should do to add support for my std::tuple<int, std::string> and future less common return values. 
Could anyone that has done this before please tell me what to do or where to look for some examples?

Kind regards, Nico




Emile Cormier

unread,
Jun 29, 2016, 6:16:50 PM6/29/16
to CppWAMP
Nico,

You must include <cppwamp/types/tuple.hpp> to enable support for converting to/from tuples.

The Conversions page of the tutorial covers how to make your custom types convertable, and lists the STL/Boost container types already supported by CppWAMP. The approach for making your custom types convertable is similar to (and has been inspired from) the approach used by the Boost.Serialization library.

Cheers,
Emile

Emile Cormier

unread,
Jun 29, 2016, 6:23:05 PM6/29/16
to CppWAMP
Also, the provided timeclient and timeserver examples show how to make the std::tm struct convertable.
Reply all
Reply to author
Forward
0 new messages