diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dbTypes.h | 3 | ||||
-rw-r--r-- | lib/helpers.h | 7 | ||||
-rw-r--r-- | lib/input/mysqlBindings.h | 3 | ||||
-rw-r--r-- | lib/output/pq/pqBindings.h | 10 |
4 files changed, 9 insertions, 14 deletions
diff --git a/lib/dbTypes.h b/lib/dbTypes.h index 42b242b..31793e4 100644 --- a/lib/dbTypes.h +++ b/lib/dbTypes.h @@ -107,9 +107,8 @@ namespace MyGrate { return std::string {i}; } - template<HasToString I> std::string - operator()(const I & i) const + operator()(const HasToString auto & i) const { return std::to_string(i); } diff --git a/lib/helpers.h b/lib/helpers.h index 5bf1bd8..f09a206 100644 --- a/lib/helpers.h +++ b/lib/helpers.h @@ -8,9 +8,8 @@ #include <utility> namespace MyGrate { - template<std::integral I> constexpr inline auto - bitslice(const I i, uint8_t offset, uint8_t size) + bitslice(const std::integral auto i, uint8_t offset, uint8_t size) { return (i >> offset) & ((1U << size) - 1U); } @@ -25,9 +24,8 @@ namespace MyGrate { return expr; } - template<typename T> constexpr inline auto - mod100_extract(T & i) + mod100_extract(std::integral auto & i) { const auto r {i % 100}; i /= 100; @@ -41,6 +39,7 @@ namespace MyGrate { std::to_string(a) } -> std::same_as<std::string>; }; + template<typename T> concept Viewable = requires(T a) { diff --git a/lib/input/mysqlBindings.h b/lib/input/mysqlBindings.h index ccf876e..3d1ad7f 100644 --- a/lib/input/mysqlBindings.h +++ b/lib/input/mysqlBindings.h @@ -58,9 +58,8 @@ namespace MyGrate::Input { b.buffer = nullptr; b.is_null = &data.emplace_back(0, 1).null; } - template<typename T> void - operator()(const T &) + operator()(const auto &) { throw std::logic_error("Not implemented"); } diff --git a/lib/output/pq/pqBindings.h b/lib/output/pq/pqBindings.h index 2a4ac8c..329a2cf 100644 --- a/lib/output/pq/pqBindings.h +++ b/lib/output/pq/pqBindings.h @@ -2,6 +2,7 @@ #define MYGRATE_OUTPUT_PQ_PQBINDINGS #include <compileTimeFormatter.h> +#include <concepts> #include <dbTypes.h> #include <helpers.h> #include <initializer_list> @@ -21,23 +22,20 @@ namespace MyGrate::Output::Pq { v.visit(*this); } } - template<Stringable T> void - operator()(const T & v) + operator()(const Stringable auto & v) { addBuf(std::to_string(v)); } - template<Viewable T> void - operator()(const T & v) + operator()(const Viewable auto & v) { values.emplace_back(v.data()); lengths.emplace_back(v.size()); formats.push_back(1); } - template<typename T> void - operator()(const T & v) + operator()(const auto & v) { addBuf(scprintf<"%?">(v)); } |