diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/openvic-dataloader/csv/LineObject.hpp | 24 | ||||
-rw-r--r-- | include/openvic-dataloader/detail/OptionalConstexpr.hpp | 9 | ||||
-rw-r--r-- | include/openvic-dataloader/detail/VectorConstexpr.hpp | 9 |
3 files changed, 31 insertions, 11 deletions
diff --git a/include/openvic-dataloader/csv/LineObject.hpp b/include/openvic-dataloader/csv/LineObject.hpp index 0494ffb..8a9c2ec 100644 --- a/include/openvic-dataloader/csv/LineObject.hpp +++ b/include/openvic-dataloader/csv/LineObject.hpp @@ -10,6 +10,8 @@ #include <tuple> #include <vector> +#include <openvic-dataloader/detail/VectorConstexpr.hpp> + namespace ovdl::csv { /// LineObject should be able to recognize the differences between: /// Input -> Indexes == "" @@ -30,20 +32,20 @@ namespace ovdl::csv { using inner_value_type = std::string; using container_type = std::vector<std::tuple<position_type, inner_value_type>>; - constexpr LineObject() = default; - constexpr LineObject(LineObject&) = default; - constexpr LineObject(LineObject&&) = default; - constexpr LineObject(const LineObject&) = default; + OVDL_VECTOR_CONSTEXPR LineObject() = default; + OVDL_VECTOR_CONSTEXPR LineObject(LineObject&) = default; + OVDL_VECTOR_CONSTEXPR LineObject(LineObject&&) = default; + OVDL_VECTOR_CONSTEXPR LineObject(const LineObject&) = default; - constexpr LineObject& operator=(const LineObject& other) = default; - constexpr LineObject& operator=(LineObject&& other) = default; + OVDL_VECTOR_CONSTEXPR LineObject& operator=(const LineObject& other) = default; + OVDL_VECTOR_CONSTEXPR LineObject& operator=(LineObject&& other) = default; - constexpr ~LineObject() = default; + OVDL_VECTOR_CONSTEXPR ~LineObject() = default; - constexpr LineObject(std::initializer_list<value_type> pos_and_val) : container_type(pos_and_val) { + OVDL_VECTOR_CONSTEXPR LineObject(std::initializer_list<value_type> pos_and_val) : container_type(pos_and_val) { } - constexpr LineObject(position_type prefix_end, std::initializer_list<value_type> pos_and_val, position_type suffix_end = 0) + OVDL_VECTOR_CONSTEXPR LineObject(position_type prefix_end, std::initializer_list<value_type> pos_and_val, position_type suffix_end = 0) : container_type(pos_and_val), _prefix_end(prefix_end), _suffix_end(suffix_end) { @@ -77,8 +79,8 @@ namespace ovdl::csv { private: // Should be position of first valid value on line - position_type _prefix_end; + position_type _prefix_end = 0; // Should be position after last value or position after last seperator - position_type _suffix_end; + position_type _suffix_end = 0; }; }
\ No newline at end of file diff --git a/include/openvic-dataloader/detail/OptionalConstexpr.hpp b/include/openvic-dataloader/detail/OptionalConstexpr.hpp new file mode 100644 index 0000000..bcb12a7 --- /dev/null +++ b/include/openvic-dataloader/detail/OptionalConstexpr.hpp @@ -0,0 +1,9 @@ +#pragma once + +// THANK YOU APPLE FOR YOUR UTTER DISREGARD FOR C++20 + +#if __cpp_lib_optional >= 202106L +#define OVDL_OPTIONAL_CONSTEXPR constexpr +#else +#define OVDL_OPTIONAL_CONSTEXPR inline +#endif
\ No newline at end of file diff --git a/include/openvic-dataloader/detail/VectorConstexpr.hpp b/include/openvic-dataloader/detail/VectorConstexpr.hpp new file mode 100644 index 0000000..7e7fa34 --- /dev/null +++ b/include/openvic-dataloader/detail/VectorConstexpr.hpp @@ -0,0 +1,9 @@ +#pragma once + +// THANK YOU APPLE FOR YOUR UTTER DISREGARD FOR C++20 + +#if __cpp_lib_constexpr_vector >= 201907L +#define OVDL_VECTOR_CONSTEXPR constexpr +#else +#define OVDL_VECTOR_CONSTEXPR inline +#endif
\ No newline at end of file |