|
Boost : |
Subject: Re: [boost] [GSoC] [Boost.Hana] Formal review request
From: Roland Bock (rbock_at_[hidden])
Date: 2014-08-03 11:15:34
On 2014-08-03 11:05, Michael Shepanski wrote:
> On 3/08/2014 5:58 PM, Roland Bock wrote:
>> namespace detail
>> {
>> template<typename... T>
>> struct wrong
>> {
>> using type = std::false_type;
>> };
>> }
>> template<typename... T>
>> using wrong_t = typename detail::wrong<T...>::type;
>>
>> It can be used to defer static_assert until a template is instantiated
>> which is an error since it is prohibited:
>>
>> // disabled default case, slightly shortened from [2]
>>
>> template<typename Context, typename T>
>> struct serializer_t
>> {
>> static_assert(wrong_t<serializer_t>::value,
>> "missing serializer specialization");
>> };
>
> I saw this in your "template toffees" talk and I wondered then whether
> it wouldn't be simpler to do this:
>
> template<typename Context, typename T, bool deferred_false = false>
> struct serializer_t
> {
> static_assert(deferred_false, "missing serializer specialization");
> };
Sure, that works too, but it introduces a template parameter, which does
not really belong there. The technique with the wrong_t can be used
without adding such artifacts to the interface.
Regards,
Roland
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk