On 2014-08-03 11:05, Michael Shepanski wrote:
On 3/08/2014 5:58 PM, Roland Bock wrote:
namespace detail { template
struct wrong { using type = std::false_type; }; } template using wrong_t = typename detail::wrong ::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
struct serializer_t { static_assert(wrong_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
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