1 #ifndef SIPLASPLAS_UTILITY_STATICIF_HPP     2 #define SIPLASPLAS_UTILITY_STATICIF_HPP     5 #include "identity.hpp"    32 template<
bool Condition>
    40         constexpr ElseBypass(T&& value) :
    41             _value{std::move(value)}
    44         template<
typename Body>
    45         constexpr T Else(
const Body&)
    47             return std::move(_value);
    58         constexpr ElseBypass(T& value) :
    62         template<
typename Body>
    63         constexpr T& Else(
const Body&)
    65             return static_cast<T&
>(*this);
    68         constexpr 
operator T&()
    82     template<
typename Body, 
typename... Args>
    83     constexpr 
auto Then(
const Body& body, Args&&... args) ->
    84         typename std::enable_if<
    85             !std::is_void<decltype(body(::cpp::Identity(), std::forward<Args>(args)...))>::value,
    86             ElseBypass<decltype(body(::
cpp::Identity(), std::forward<Args>(args)...))>
    92     template<
typename Body, 
typename... Args>
    93     constexpr 
auto Then(
const Body& body, Args&&... args) ->
    94         typename std::enable_if<
    95             std::is_void<decltype(body(::cpp::Identity(), std::forward<Args>(args)...))>::value,
   104     template<
typename Body, 
typename... Args>
   105     constexpr 
void Else(
const Body&, Args&&...)
   115     constexpr 
If() = 
default;
   117     template<
typename Body, 
typename... Args>
   118     constexpr 
If& Then(
const Body&, Args&&...)
   123     template<
typename Body, 
typename... Args>
   124     constexpr decltype(
auto) Else(
const Body& body, Args&&... args)
   126         return body(
Identity(), std::forward<Args>(args)...);
   244 template<
bool Condition, 
typename ThenBody, 
typename... Args>
   245 auto staticIf(
const ThenBody& thenBody, Args&&... args)
   248     return if_.Then(thenBody, std::forward<Args>(args)...);
   253 #endif // SIPLASPLAS_UTILITY_STATICIF_HPP A functor class implementing the identity function. 
Definition: identity.hpp:21
 
Definition: canary_allocator.hpp:7
 
auto staticIf(const ThenBody &thenBody, Args &&...args)
Implements an static conditional. 
Definition: staticif.hpp:245
 
Implements the then branch of an static conditional. 
Definition: staticif.hpp:33