Skip to content

Commit

Permalink
Continue prep work for v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Apr 6, 2024
1 parent 3d2bd0b commit 2916578
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 58 deletions.
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
Ianpike98@gmail.com.
Ianpike98(at)gmail(dot)com.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ CCmath is an open-source project, and it needs your help to go on growing and im
|----------------|--------|---------------------------------------------------------------------------------------|
| abs | 100 | |
| fdim | 100 | |
| fma | 100 | Functional but more fallbacks are desired. |
| fma | 100 | Functional. Faster implementations desired. |
| (f)max | 100 | |
| (f)min | 100 | |
| remainder | 100 | |
Expand Down
1 change: 1 addition & 0 deletions ccmath_headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set(ccmath_internal_support_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/ctz.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/type_identity.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/always_false.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/limits.hpp
)

set(ccmath_internal_types_headers
Expand Down
44 changes: 22 additions & 22 deletions include/ccmath/internal/support/limits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,42 @@ namespace ccm::support
{
enum class float_round_style : std::int8_t
{
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_toward_neg_infinity = 3
};

template<class T, bool = std::is_arithmetic_v<T>>
template <class T, bool = std::is_arithmetic_v<T>>
class numeric_limits
{
public:
using type = T;

static constexpr const bool is_specialized = std::numeric_limits<type>::is_specialized;
[[nodiscard]] static constexpr type min() noexcept { return std::numeric_limits<type>::min(); }
[[nodiscard]] static constexpr type max() noexcept { return std::numeric_limits<type>::max(); }
[[nodiscard]] static constexpr type lowest() noexcept { return std::numeric_limits<type>::lowest(); }
static constexpr const int digits = std::numeric_limits<type>::digits;
static constexpr const int digits10 = std::numeric_limits<type>::digits10;
[[nodiscard]] static constexpr type max() noexcept { return std::numeric_limits<type>::max(); }
[[nodiscard]] static constexpr type lowest() noexcept { return std::numeric_limits<type>::lowest(); }

static constexpr const int digits = std::numeric_limits<type>::digits;
static constexpr const int digits10 = std::numeric_limits<type>::digits10;
static constexpr const int max_digits10 = std::numeric_limits<type>::max_digits10;
static constexpr const bool is_signed = std::numeric_limits<type>::is_signed;
static constexpr const bool is_integer = std::numeric_limits<type>::is_integer;
static constexpr const bool is_exact = std::numeric_limits<type>::is_exact;
static constexpr const int radix = std::numeric_limits<type>::radix;
static constexpr const bool is_signed = std::numeric_limits<type>::is_signed;
static constexpr const bool is_integer = std::numeric_limits<type>::is_integer;
static constexpr const bool is_exact = std::numeric_limits<type>::is_exact;
static constexpr const int radix = std::numeric_limits<type>::radix;
[[nodiscard]] static constexpr type epsilon() noexcept { return std::numeric_limits<type>::epsilon(); }
[[nodiscard]] static constexpr type round_error() noexcept { return std::numeric_limits<type>::round_error(); }

static constexpr const int min_exponent = std::numeric_limits<type>::min_exponent;
static constexpr const int min_exponent = std::numeric_limits<type>::min_exponent;
static constexpr const int min_exponent10 = std::numeric_limits<type>::min_exponent10;
static constexpr const int max_exponent = std::numeric_limits<type>::max_exponent;
static constexpr const int max_exponent = std::numeric_limits<type>::max_exponent;
static constexpr const int max_exponent10 = std::numeric_limits<type>::max_exponent10;

static constexpr const bool has_infinity = std::numeric_limits<type>::has_infinity;
static constexpr const bool has_quiet_NaN = std::numeric_limits<type>::has_quiet_NaN;
static constexpr const bool has_signaling_NaN = std::numeric_limits<type>::has_signaling_NaN;
static constexpr const bool has_infinity = std::numeric_limits<type>::has_infinity;
static constexpr const bool has_quiet_NaN = std::numeric_limits<type>::has_quiet_NaN;
static constexpr const bool has_signaling_NaN = std::numeric_limits<type>::has_signaling_NaN;
[[nodiscard]] static constexpr type infinity() noexcept { return std::numeric_limits<type>::infinity(); }
[[nodiscard]] static constexpr type quiet_NaN() noexcept { return std::numeric_limits<type>::quiet_NaN(); }
[[nodiscard]] static constexpr type signaling_NaN() noexcept { return std::numeric_limits<type>::signaling_NaN(); }
Expand All @@ -64,8 +64,8 @@ namespace ccm::support
static constexpr const bool is_bounded = std::numeric_limits<type>::is_bounded;
static constexpr const bool is_modulo = std::numeric_limits<type>::is_modulo;

static constexpr const bool traps = std::numeric_limits<type>::traps;
static constexpr const bool tinyness_before = std::numeric_limits<type>::tinyness_before;
static constexpr const bool traps = std::numeric_limits<type>::traps;
static constexpr const bool tinyness_before = std::numeric_limits<type>::tinyness_before;
static constexpr const float_round_style round_style = static_cast<float_round_style>(std::numeric_limits<type>::round_style);
};
} // namespace ccm::support
50 changes: 23 additions & 27 deletions include/ccmath/internal/support/meta_compare.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,43 @@ namespace ccm::support
namespace detail
{
// A variadic alias template that resolves to its first argument.
template<typename T, typename...>
template <typename T, typename...>
using first_t = T;

// These are deliberately not defined.
template<typename... Bn>
auto or_fn(int) -> first_t<std::false_type,
std::enable_if_t<!bool(Bn::value)>...>;
template <typename... Bn>
auto or_fn(int) -> first_t<std::false_type, std::enable_if_t<!bool(Bn::value)>...>;

template<typename... Bn>
template <typename... Bn>
auto or_fn(...) -> std::true_type;

template<typename... Bn>
auto and_fn(int) -> first_t<std::true_type,
std::enable_if_t<bool(Bn::value)>...>;
template <typename... Bn>
auto and_fn(int) -> first_t<std::true_type, std::enable_if_t<bool(Bn::value)>...>;

template<typename... Bn>
template <typename... Bn>
auto and_fn(...) -> std::false_type;
} // namespace detail

template<typename... Bn>
struct or_
: decltype(detail::or_fn<Bn...>(0))
{ };
template <typename... Bn>
struct or_ : decltype(detail::or_fn<Bn...>(0))
{
};

template<typename... Bn>
struct and_
: decltype(detail::and_fn<Bn...>(0))
{ };
template <typename... Bn>
struct and_ : decltype(detail::and_fn<Bn...>(0))
{
};

template<typename Pp>
struct not_
: std::bool_constant<!bool(Pp::value)>
{ };
template <typename Pp>
struct not_ : std::bool_constant<!bool(Pp::value)>
{
};
/// @endcond

template<typename... Bn>
template <typename... Bn>
inline constexpr bool or_v = or_<Bn...>::value;
template<typename... Bn>
template <typename... Bn>
inline constexpr bool and_v = and_<Bn...>::value;
template<typename Pp>
template <typename Pp>
inline constexpr bool not_v = not_<Pp>::value;


}
} // namespace ccm::support
14 changes: 7 additions & 7 deletions include/ccmath/internal/support/unreachable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#if defined(__cpp_lib_unreachable) && __cpp_lib_unreachable >= 202202L
#include <utility>
#include <utility>
#endif

namespace ccm
Expand All @@ -22,12 +22,12 @@ namespace ccm
std::unreachable();
#elif defined(_MSC_VER) && !defined(__clang__) // MSVC
__assume(false);
#elif defined(__GNUC__) || defined(__clang__) // GCC, Clang
__builtin_unreachable();
#else // Fallback
// In the event that no compiler specific extension is available
// Then do nothing.
static_cast<void>(0);
#elif defined(__GNUC__) || defined(__clang__) // GCC, Clang
__builtin_unreachable();
#else // Fallback
// In the event that no compiler specific extension is available
// Then do nothing.
static_cast<void>(0);
#endif
}

Expand Down

0 comments on commit 2916578

Please sign in to comment.