From 342e5b1b5aa555d7a910e2fdc150c6fe0823e065 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 19 Dec 2025 19:03:11 +0100 Subject: feat! equiv.hpp include, which deprecates is_same.hpp. Signed-off-by: Amlal El Mahrouss --- include/ocl/equiv.hpp | 64 ++++++++++++++++++++++++++++ include/ocl/is_same.hpp | 108 ++++-------------------------------------------- include/ocl/option.hpp | 10 ++--- 3 files changed, 76 insertions(+), 106 deletions(-) create mode 100644 include/ocl/equiv.hpp (limited to 'include') 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 + +/// @brief OCL equivalence namespace. +namespace ocl +{ + template + 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 + struct is_real final + { + using type = T; + static constexpr auto value = false; + }; + + template + struct equiv_to final + { + using left_type = L; + using right_type = R; + + static constexpr auto value = false; + }; + + template + struct equiv_to final + { + static constexpr auto value = true; + }; + + template <> + struct is_real final + { + static constexpr auto value = true; + }; + + template <> + struct is_real 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 +#include -/// @brief OCL equivalence namespace. -namespace ocl -{ - template - 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 - struct is_same - { - using left_type = T; - using right_type = T; - - static constexpr bool value = false; - }; - - template - struct is_same - { - static constexpr bool value = true; - }; - - template - struct is_not_same - { - using left_type = T; - using right_type = T; - - static constexpr bool value = true; - }; - - template - struct is_not_same - { - static constexpr bool value = false; - }; - - template - struct equiv_is_int8 final - { - using result_type = bool; - - static constexpr auto value = sizeof(T) == 1; - }; - - template - struct equiv_not_int8 final - { - using result_type = bool; - - static constexpr auto value = sizeof(T) > 1; - }; - - template - struct equiv_is_real final - { - using result_type = bool; - - static constexpr auto value = sizeof(T) >= 4; - }; - - template - struct equiv_is final - { - using result_type = bool; - using left_type = L; - using right_type = R; - - static constexpr auto value = false; - }; - - template - struct equiv_is 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 @@ -151,4 +151,4 @@ namespace ocl } } // namespace ocl -#endif /* ifndef __OCL_CORE_OPTION */ \ No newline at end of file +#endif /* ifndef __OCL_CORE_OPTION */ -- cgit v1.2.3