|
Boost : |
Subject: Re: [boost] Boost.Hana - Type Classes, data types and categories (tags).
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2014-09-21 08:28:45
Le 17/09/14 23:30, Vicente J. Botet Escriba a écrit :
> Le 17/09/14 22:49, Louis Dionne a écrit :
>> Vicente J. Botet Escriba <vicente.botet <at> wanadoo.fr> writes:
>
>>> In addition, I wonder if the category associated shouldn't depend on
>>> the
>>> type class we want to map.
>>>
>>> TC::Instance<category_t<T, TC>>
>> I'm not sure why that would be useful. Do you have a use case in mind?
>
> After more thoughts the user can always specialize TC::Instance<T>
> inheriting from TC::Instance<CatA>.
>
> struct TC::Instance<T> : TC::Instance<CatA> {};
>
A deeper analysis of your code let me think that you have already
something similar to what I was requesting.
#define
BOOST_HANA_TYPECLASS(NAME) \
/** @cond
*/ \
template <typename T, typename =
void> \
struct
instance \
: instance<T,
::boost::hana::when<true>> \
{
}; \
\
template <typename
T> \
struct instance<T, decltype((void)(typename T::hana_ ##
NAME*)0)> \
: T::hana_ ##
NAME \
{
}; \
The previous specialization let the data type class define directly how
is it could be seen as an instance of a given type class NAME.
I see however that this has been used only fro the Record type class.
boost/hana/record/macros.hpp: struct hana_Record :
::boost::hana::Record::mcd { \
So here you have the use_case you were requesting.
Best,.
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk