Library: relocate signature-detection macro

This macro has turned out to be quite useful in cases
where a generic setup / algorithm / builder need to be customised
with λ adaptors for binding to local or custom types. It relies
on the metafunctions defined in lib/meta/function.hpp to match
the signature of "anything function-like"; so this seems the
proper place to provide that macro alongside
This commit is contained in:
Fischlurch 2023-05-04 12:35:23 +02:00
parent c8f879ff3f
commit 1f83e5209b
3 changed files with 27 additions and 32 deletions

View file

@ -285,27 +285,10 @@ namespace diff{
namespace { // Mutator-Builder decorator components...
using lib::meta::_Fun;
using std::forward;
using std::move;
template<typename FUN, typename SIG>
struct has_Sig
: std::is_same<SIG, typename _Fun<FUN>::Sig>
{ };
/** verify the installed functors or lambdas expose the expected signature */
#define ASSERT_VALID_SIGNATURE(_FUN_, _SIG_) \
static_assert (has_Sig<_FUN_, _SIG_>::value, "Function " STRINGIFY(_FUN_) " unsuitable, expected signature: " STRINGIFY(_SIG_));
/**
* Builder-DSL to create and configure a concrete TreeMutator
* @remarks all generated follow-up builders are chained and

View file

@ -178,6 +178,31 @@ namespace meta{
/**
* Meta-function to check that some _function like_ entity
* offers the expected signature
* @tparam SIG signature type (e.g. `float(int, bool)`)
* @tparam FUN anything _function like_ (class with function call operator
* or std::function instance, or λ instance or language function
* reference or function pointer
*/
template<typename FUN, typename SIG>
struct has_Sig
: std::is_same<SIG, typename _Fun<FUN>::Sig>
{ };
/**
* Macro for a compile-time check to verify the given
* generic functors or lambdas expose some expected signature.
* @remark typically used when configuring a template with custom adapters.
*/
#define ASSERT_VALID_SIGNATURE(_FUN_, _SIG_) \
static_assert (lib::meta::has_Sig<_FUN_, _SIG_>::value, \
"Function " STRINGIFY(_FUN_) " unsuitable, expected signature: " STRINGIFY(_SIG_));

View file

@ -32,9 +32,8 @@
#define LIB_SPLIT_SPLICE_H
#include "lib/error.hpp"
//#include "steam/mobject/builder/fixture-change-detector.hpp" ///////////TODO
#include "lib/time/timevalue.hpp"
#include "lib/meta/function.hpp"
#include "lib/time/timevalue.hpp"
#include "lib/nocopy.hpp"
#include <array>
@ -45,19 +44,7 @@ namespace lib {
namespace error = lumiera::error;
namespace splitsplice {// Implementation of Split-Splice algorithm
using lib::meta::_Fun;
template<typename FUN, typename SIG>
struct has_Sig
: std::is_same<SIG, typename _Fun<FUN>::Sig>
{ };
/** verify the installed functors or lambdas expose the expected signature */
#define ASSERT_VALID_SIGNATURE(_FUN_, _SIG_) \
static_assert (has_Sig<_FUN_, _SIG_>::value, "Function " STRINGIFY(_FUN_) " unsuitable, expected signature: " STRINGIFY(_SIG_));
namespace splitsplice {/// Implementation of [»SplitSplice« algorithm](\ref splite-splice.cpp)
/**