|
Boost : |
Subject: Re: [boost] [GSoC] [Boost.Hana] Formal review request
From: pfultz2 (pfultz2_at_[hidden])
Date: 2014-08-03 09:37:26
> b) You have one or more full or partial class specializations for
> specific classes/templates/values:
>
> Basically as above, but if you want to prohibited the default case or
> certain specializations, here's a nice, minimalistic helper to do so
This is a perfect example of when *not* to use static_assert. You should
leave
the class undefined:
template<typename Context, typename T, typename Enable = void>
struct serializer_t;
Then the compiler will already give a simple and informative error about the
class being undefined, which is almost the same error you put in the
static_assert.
Futhermore, say I want to know if there is a valid serializer at
compile-time
and if not then choose a different method. So, I create a predicate to
detect
a valid serializer:
TICK_TRAIT(has_serializer)
{
template<class Context, class T>
auto requires_(Context ctx, const T& x) -> decltype(
has_type<typename Context::T, T>(),
Context::_(x, ctx)
);
};
Unfortunately, this won't work because of the hard error, and it won't work
with Concepts Lite either.
`static_assert` can be used to check variants outside of type requirements,
but
in general, it should not be used for type requirements.
-- View this message in context: http://boost.2283326.n4.nabble.com/Re-GSoC-Boost-Hana-Formal-review-request-tp4665622p4665966.html Sent from the Boost - Dev mailing list archive at Nabble.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk