From 66c758f13aeda9cec817548cd7a8c4f6d1af324a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 3 Dec 2016 18:44:09 +0100 Subject: [PATCH] implemented a SFINAE compile-time checker for receive policies --- check_policy.hpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 check_policy.hpp diff --git a/check_policy.hpp b/check_policy.hpp new file mode 100644 index 0000000..201c2ad --- /dev/null +++ b/check_policy.hpp @@ -0,0 +1,24 @@ +#pragma once +#include +#include "chat_messages.hpp" + + + +/* SFINAE compile-type checker for receive policies (as defined in chat_networking.hpp) + * it checks whether PolicyCandidate supplies all of the following methods: + * - void message_do_what(chat_message) */ +template +struct is_valid_policy : std::false_type {}; + +template +struct is_valid_policy< + PolicyCandidate, + typename + std::enable_if< + std::is_same< + decltype(PolicyCandidate + ::message_do_what(std::declval())), + void + >::value + >::type> +: std::true_type {}; \ No newline at end of file