|
Boost : |
Subject: Re: [boost] Formal Review Request: Boost.Convert
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-02-24 17:09:38
Emil Dotchevski wrote:
> Andrey, a question: let's say I am the author of a uuid type, something like:
>
> struct uuid
> {
> unsigned char value_[16];
> };
>
> How do I integrate that type in the proposed convert framework, so it
> can be converted to std::string? I have a basic understanding, but I
> wanted to see a clear picture of only the things relevant to defining
> a conversion (as opposed to using it.)
With the code snippet I attached it should look something like this:
struct uuid_to_string_tag {};
template< typename ToT >
typename enable_if<
is_string< ToT >,
uuid_to_string_tag
>::type get_conversion_tag(uuid*, ToT*);
template< >
struct converter_impl< uuid, uuid_to_string_tag >
{
typedef uuid result_type;
template< typename ArgsT >
result_type operator() (ArgsT const& args) const;
};
The operator() will contain the conversion code.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk