Moved always_false template to utils
This commit is contained in:
parent
1ca8ea2061
commit
778f5f9754
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
#include "utils.hpp"
|
||||||
|
|
||||||
#include "../io/io.hpp"
|
#include "../io/io.hpp"
|
||||||
|
|
||||||
@ -8,6 +9,8 @@ namespace uart {
|
|||||||
|
|
||||||
template <io::P rxPin, io::P txPin, class cfg = Config<>>
|
template <io::P rxPin, io::P txPin, class cfg = Config<>>
|
||||||
class Software {
|
class Software {
|
||||||
|
static_assert(util::always_false_v<cfg>, "Not implemented");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using data_t = typename cfg::data_t;
|
using data_t = typename cfg::data_t;
|
||||||
static constexpr auto DATA_BITS = cfg::DATA_BITS;
|
static constexpr auto DATA_BITS = cfg::DATA_BITS;
|
||||||
|
70
uart.hpp
70
uart.hpp
@ -4,6 +4,7 @@
|
|||||||
#include "hardware0.hpp"
|
#include "hardware0.hpp"
|
||||||
#include "hardware1.hpp"
|
#include "hardware1.hpp"
|
||||||
#include "software.hpp"
|
#include "software.hpp"
|
||||||
|
#include "utils.hpp"
|
||||||
|
|
||||||
#include "../flash/flash.hpp"
|
#include "../flash/flash.hpp"
|
||||||
|
|
||||||
@ -11,15 +12,6 @@
|
|||||||
|
|
||||||
namespace uart {
|
namespace uart {
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template <typename...>
|
|
||||||
struct always_false {
|
|
||||||
static constexpr auto value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template <class Driver>
|
template <class Driver>
|
||||||
class Uart {
|
class Uart {
|
||||||
public:
|
public:
|
||||||
@ -91,91 +83,91 @@ class Uart {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(char)
|
Uart &operator<<(char)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(unsigned char)
|
Uart &operator<<(unsigned char)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(short)
|
Uart &operator<<(short)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(unsigned short)
|
Uart &operator<<(unsigned short)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(int)
|
Uart &operator<<(int)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(unsigned int)
|
Uart &operator<<(unsigned int)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(long)
|
Uart &operator<<(long)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(unsigned long)
|
Uart &operator<<(unsigned long)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(long long)
|
Uart &operator<<(long long)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(unsigned long long)
|
Uart &operator<<(unsigned long long)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(float)
|
Uart &operator<<(float)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(double)
|
Uart &operator<<(double)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(long double)
|
Uart &operator<<(long double)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(bool)
|
Uart &operator<<(bool)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(const void *)
|
Uart &operator<<(const void *)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -184,91 +176,91 @@ class Uart {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(char &)
|
Uart &operator>>(char &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned char &)
|
Uart &operator>>(unsigned char &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(short &)
|
Uart &operator>>(short &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned short &)
|
Uart &operator>>(unsigned short &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(int &)
|
Uart &operator>>(int &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned int &)
|
Uart &operator>>(unsigned int &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(long &)
|
Uart &operator>>(long &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned long &)
|
Uart &operator>>(unsigned long &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(long long &)
|
Uart &operator>>(long long &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned long long &)
|
Uart &operator>>(unsigned long long &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(float &)
|
Uart &operator>>(float &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(double &)
|
Uart &operator>>(double &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(long double &)
|
Uart &operator>>(long double &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(bool &)
|
Uart &operator>>(bool &)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(const void *&)
|
Uart &operator>>(const void *&)
|
||||||
{
|
{
|
||||||
static_assert(detail::always_false<Ts...>::value, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
15
utils.hpp
Normal file
15
utils.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace uart {
|
||||||
|
namespace util {
|
||||||
|
|
||||||
|
template <typename...>
|
||||||
|
struct always_false {
|
||||||
|
static constexpr auto value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename... Ts>
|
||||||
|
static constexpr auto always_false_v = always_false<Ts...>::value;
|
||||||
|
|
||||||
|
} // namespace util
|
||||||
|
} // namespace uart
|
Loading…
Reference in New Issue
Block a user