From 7ba674c29a1996813787bd8e5e71fffece7b0b1a Mon Sep 17 00:00:00 2001 From: Cheng Date: Mon, 2 Oct 2023 01:49:03 +0000 Subject: [PATCH] Cajoled visual studio into issuing intelligent error messages when an unserializable type is in the parameter pack. --- src/ristretto255.h | 4 +++- src/serialization.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ristretto255.h b/src/ristretto255.h index 91b0e30..30cc919 100644 --- a/src/ristretto255.h +++ b/src/ristretto255.h @@ -195,10 +195,12 @@ namespace ristretto255 { if (i) throw HashReuseException(); } template< has_machine_independent_representation T, typename... Args>explicit hash(const T& first, Args... args) { + // not restraining the variant args by concept, because they get caught deeper in, + // and visual studio reporting of variant concept errors sucks. hsh in; in << first; if constexpr (sizeof...(args) > 0) { - in.hashinto( args...); + in.hashinto( ro::trigger_error(args)...); } int i = crypto_generichash_blake2b_final( &in.st, diff --git a/src/serialization.h b/src/serialization.h index 7c4c997..0eaf4ca 100644 --- a/src/serialization.h +++ b/src/serialization.h @@ -317,6 +317,9 @@ template concept has_machine_independent_representation = serializable(); + template + T trigger_error(T x) { return x; }; + static_assert( !has_machine_independent_representation && has_machine_independent_representation, char*, std::span>, "concepts needed");