diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-19 19:03:11 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-19 19:06:36 +0100 |
| commit | 342e5b1b5aa555d7a910e2fdc150c6fe0823e065 (patch) | |
| tree | 4c99cc76bf028589c238f0daba8e9229ff89ffd8 /include | |
| parent | c87aa0ceca04810350c0bf1dfcefad1286982e26 (diff) | |
feat! equiv.hpp include, which deprecates is_same.hpp.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/ocl/equiv.hpp | 64 | ||||
| -rw-r--r-- | include/ocl/is_same.hpp | 108 | ||||
| -rw-r--r-- | include/ocl/option.hpp | 10 |
3 files changed, 76 insertions, 106 deletions
diff --git a/include/ocl/equiv.hpp b/include/ocl/equiv.hpp new file mode 100644 index 0000000..ac6e2cd --- /dev/null +++ b/include/ocl/equiv.hpp @@ -0,0 +1,64 @@ +/* + * File: equiv.hpp + * Purpose: Equivalence header. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License. + */ + +#ifndef __OCL_CORE_EQUIV +#define __OCL_CORE_EQUIV + +#include <ocl/detail/config.hpp> + +/// @brief OCL equivalence namespace. +namespace ocl +{ + template <class T> + struct basic_hash final + { + using result_type = typename T::result_type; + using type = T; + + // AMLALE: If it throws, we can't compute the hash correctly. + constexpr result_type hash() noexcept + { + return type{}.hash(); + } + }; + + template <typename T> + struct is_real final + { + using type = T; + static constexpr auto value = false; + }; + + template <typename L, typename R> + struct equiv_to final + { + using left_type = L; + using right_type = R; + + static constexpr auto value = false; + }; + + template <typename L> + struct equiv_to<L, L> final + { + static constexpr auto value = true; + }; + + template <> + struct is_real<double> final + { + static constexpr auto value = true; + }; + + template <> + struct is_real<float> final + { + static constexpr auto value = true; + }; +} // namespace ocl + +#endif diff --git a/include/ocl/is_same.hpp b/include/ocl/is_same.hpp index b8b5ccf..4ed0dc7 100644 --- a/include/ocl/is_same.hpp +++ b/include/ocl/is_same.hpp @@ -1,104 +1,10 @@ -/* - * File: is_same.hpp - * Purpose: Equivalence header. - * Author: Amlal El Mahrouss (amlal@nekernel.org) - * Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License. - */ +#pragma once -#ifndef __OCL_CORE_IS_SAME -#define __OCL_CORE_IS_SAME +#if __cplusplus <= 202301L +#error "This header has been deprecated, it now redirects to equiv.hpp" +#else +#warning "This header has been deprecated, it now redirects to equiv.hpp" +#endif -#include <ocl/detail/config.hpp> +#include <ocl/equiv.hpp> -/// @brief OCL equivalence namespace. -namespace ocl -{ - template <typename T> - struct basic_hash final - { - using result_type = typename T::result_type; - using type = T; - - // AMLALE: If it throws, we can't compute the hash correctly. - static constexpr result_type hash() noexcept - { - return T{}.hash(); - } - }; - - template <typename T, typename U> - struct is_same - { - using left_type = T; - using right_type = T; - - static constexpr bool value = false; - }; - - template <typename T> - struct is_same<T, T> - { - static constexpr bool value = true; - }; - - template <typename T, typename U> - struct is_not_same - { - using left_type = T; - using right_type = T; - - static constexpr bool value = true; - }; - - template <typename T> - struct is_not_same<T, T> - { - static constexpr bool value = false; - }; - - template <typename T> - struct equiv_is_int8 final - { - using result_type = bool; - - static constexpr auto value = sizeof(T) == 1; - }; - - template <typename T> - struct equiv_not_int8 final - { - using result_type = bool; - - static constexpr auto value = sizeof(T) > 1; - }; - - template <typename T> - struct equiv_is_real final - { - using result_type = bool; - - static constexpr auto value = sizeof(T) >= 4; - }; - - template <typename L, typename R> - struct equiv_is final - { - using result_type = bool; - using left_type = L; - using right_type = R; - - static constexpr auto value = false; - }; - - template <typename L> - struct equiv_is<L, L> final - { - using result_type = bool; - using left_type = L; - using right_type = L; - - static constexpr auto value = true; - }; -} // namespace ocl - -#endif
\ No newline at end of file diff --git a/include/ocl/option.hpp b/include/ocl/option.hpp index 2fa47e9..c1c8476 100644 --- a/include/ocl/option.hpp +++ b/include/ocl/option.hpp @@ -12,7 +12,7 @@ namespace ocl { - enum struct return_type + enum struct return_type : int { invalid = 0, okay = 100, @@ -67,12 +67,12 @@ namespace ocl namespace detail { - // AMLALE: They (operator()) were marked `noexcept` as failing conditions within an evaluation (say a overloads operator==) proves that the - // predictate is wrong. + // AMLALE: The operator() are marked as `noexcept` as failing conditions within an evaluation (say a overloads operator==) proves that the + // predictate is wrong. Thus program state is undefined. struct teller { - explicit teller() = default; + teller() = default; virtual ~teller() = default; template <class ObjFirst, class ObjLast> @@ -151,4 +151,4 @@ namespace ocl } } // namespace ocl -#endif /* ifndef __OCL_CORE_OPTION */
\ No newline at end of file +#endif /* ifndef __OCL_CORE_OPTION */ |
