1
0
forked from Alepha/Alepha

Add an identity which works with TableTest

This commit is contained in:
2024-06-12 16:58:21 -04:00
parent 26eb1b080e
commit 500ad866eb
3 changed files with 61 additions and 0 deletions

34
Algorithm/identity.h Normal file
View File

@ -0,0 +1,34 @@
static_assert( __cplusplus > 2020'99 );
#pragma once
#include <Alepha/Alepha.h>
namespace Alepha::Hydrogen::Algorithm ::detail:: identity_m
{
inline namespace exports
{
/*!
* Specializable identity function.
*
* Sometimes you need an unambiguous overload for `std::identity`. Because the
* standard's version is a function object with an unbounded member template
* `operator ()`, this means that deduction contexts cannod deduce which
* type is the range and domain for the identity object passed. Normally
* this doesn't matter, but some `Alepha` constructs need to inspect functions.
* to that end, one can use `Alepha::Algorithm::identity< T >` for this purpose
*
* @note This functions effectively the same as the original SGI STL's `identity`
* extension, but with C++11's rvalue semantics. Although we also use a template
* variable to avoid the need to instantiate.
*/
template< typename T >
constexpr auto identity= []( T val ) { return val; };
}
}
namespace Alepha::Hydrogen::Algorithm::inline exports::inline identity_m
{
using namespace detail::identity_m::exports;
}