siplasplas
A library for C++ reflection and introspection
cpp::detail::If< Condition > Class Template Reference

Implements the then branch of an static conditional. More...

#include <siplasplas/utility/staticif.hpp>

Public Member Functions

template<typename Body , typename... Args>
constexpr auto Then (const Body &body, Args &&...args) -> typename std::enable_if< !std::is_void< decltype(body(::cpp::Identity(), std::forward< Args >(args)...))>::value, ElseBypass< decltype(body(::cpp::Identity(), std::forward< Args >(args)...))> >::type
 
template<typename Body , typename... Args>
constexpr auto Then (const Body &body, Args &&...args) -> typename std::enable_if< std::is_void< decltype(body(::cpp::Identity(), std::forward< Args >(args)...))>::value, If & >::type
 
template<typename Body , typename... Args>
constexpr void Else (const Body &, Args &&...)
 

Detailed Description

template<bool Condition>
class cpp::detail::If< Condition >

Implements the then branch of an static conditional.

The cpp::detail::If template implements the internals of an static_if(). The main template implements the true condition branch (The branch executing the then body). Returning values in this case may not be as efficient as possible since the returned value should bypass the then body (This involves two move operations, see cpp::If::ElseBypass):

std::string str = If<true>().Then([](auto identity)
{
return "hello, world!"s; // the string is moved twice
// to exit the static if.
});
Template Parameters
ConditionIf condition. True in the main template.

The documentation for this class was generated from the following file: