-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURES] Implemebnts dec, inc, minus, oneminus and ++/--
- Loading branch information
Showing
15 changed files
with
656 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright : KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_dec : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_dec; | ||
|
||
KYOSU_DEFERS_CALLABLE(dec_); | ||
|
||
template<eve::ordered_value T> | ||
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::dec(v); } | ||
|
||
template<typename T> | ||
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) | ||
{ | ||
return eve::tag_invoke(*this, target); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_dec(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var dec | ||
//! @brief decrements the argument by 1. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #declude <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T> constexpr T dec(T z) noexcept; | ||
//! template<eve::ordered_value T> constexpr T dec(T z) noexcept; | ||
//! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z` : Value to decrement. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! Returns its argument minus 1. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/dec.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_dec dec = {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright : KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_inc : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_inc; | ||
|
||
KYOSU_DEFERS_CALLABLE(inc_); | ||
|
||
template<eve::ordered_value T> | ||
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::inc(v); } | ||
|
||
template<typename T> | ||
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) | ||
{ | ||
return eve::tag_invoke(*this, target); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_inc(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var inc | ||
//! @brief Increments the argument. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #include <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T> constexpr T inc(T z) noexcept; | ||
//! template<eve::ordered_value T> constexpr T inc(T z) noexcept; | ||
//! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z` : Value to increment. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! Returns its argument plus 1. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/inc.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_inc inc = {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright : KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_minus : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_minus; | ||
|
||
KYOSU_DEFERS_CALLABLE(minus_); | ||
|
||
template<eve::value T> | ||
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return -v; } | ||
// there is no other implementation | ||
|
||
template<typename T> | ||
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) | ||
{ | ||
return eve::tag_invoke(*this, target); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_minus(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var minus | ||
//! @brief Computes the opposite value. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #include <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T> constexpr T minus(T z) noexcept; | ||
//! template<eve::ordered_value T> constexpr T minus(T z) noexcept; | ||
//! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z` : Value to minusugate. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! Returns the opposite of its argument. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/minus.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_minus minus = {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright : KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_oneminus : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_oneminus; | ||
|
||
KYOSU_DEFERS_CALLABLE(oneminus_); | ||
|
||
template<eve::ordered_value T> | ||
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::oneminus(v); } | ||
|
||
template<typename T> | ||
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) | ||
{ | ||
return eve::tag_invoke(*this, target); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_oneminus(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var oneminus | ||
//! @brief Computes the value 1 minus the argument. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #oneminuslude <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T> constexpr T oneminus(T z) noexcept; | ||
//! template<eve::ordered_value T> constexpr T oneminus(T z) noexcept; | ||
//! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z` : argument. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! Returns 1 minus the argument. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/oneminus.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_oneminus oneminus = {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.