From 778f5f97540adfc9f42533429581004dbb40de85 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sat, 3 Aug 2019 10:58:32 +0200 Subject: [PATCH] Moved always_false template to utils --- software.hpp | 3 +++ uart.hpp | 70 +++++++++++++++++++++++----------------------------- utils.hpp | 15 +++++++++++ 3 files changed, 49 insertions(+), 39 deletions(-) create mode 100644 utils.hpp diff --git a/software.hpp b/software.hpp index 234bf0d..2bf3ae4 100644 --- a/software.hpp +++ b/software.hpp @@ -1,6 +1,7 @@ #pragma once #include "config.hpp" +#include "utils.hpp" #include "../io/io.hpp" @@ -8,6 +9,8 @@ namespace uart { template > class Software { + static_assert(util::always_false_v, "Not implemented"); + public: using data_t = typename cfg::data_t; static constexpr auto DATA_BITS = cfg::DATA_BITS; diff --git a/uart.hpp b/uart.hpp index 3fd9a00..2d3e2ce 100644 --- a/uart.hpp +++ b/uart.hpp @@ -4,6 +4,7 @@ #include "hardware0.hpp" #include "hardware1.hpp" #include "software.hpp" +#include "utils.hpp" #include "../flash/flash.hpp" @@ -11,15 +12,6 @@ namespace uart { -namespace detail { - -template -struct always_false { - static constexpr auto value = false; -}; - -} // namespace detail - template class Uart { public: @@ -91,91 +83,91 @@ class Uart { template Uart &operator<<(char) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(unsigned char) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(short) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(unsigned short) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(int) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(unsigned int) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(long) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(unsigned long) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(long long) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(unsigned long long) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(float) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(double) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(long double) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(bool) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator<<(const void *) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } ////////////////////////////////////////////////////////////////////////// @@ -184,91 +176,91 @@ class Uart { template Uart &operator>>(char &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(unsigned char &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(short &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(unsigned short &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(int &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(unsigned int &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(long &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(unsigned long &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(long long &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(unsigned long long &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(float &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(double &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(long double &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(bool &) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } template Uart &operator>>(const void *&) { - static_assert(detail::always_false::value, "Not implemented"); + static_assert(util::always_false_v, "Not implemented"); } }; diff --git a/utils.hpp b/utils.hpp new file mode 100644 index 0000000..c9df788 --- /dev/null +++ b/utils.hpp @@ -0,0 +1,15 @@ +#pragma once + +namespace uart { +namespace util { + +template +struct always_false { + static constexpr auto value = false; +}; + +template +static constexpr auto always_false_v = always_false::value; + +} // namespace util +} // namespace uart