10#if !defined (HPP_ALIB_EXPRESSIONS_PLUGINS_ELVIS)
18namespace alib {
namespace expressions {
namespace plugins {
26Box elvis( Scope&, ArgIterator arg, ArgIterator )
28 return (*arg).
Call<FIsTrue>() ? *arg : *(arg + 1);
33bool ElvisOperator::TryCompilation( CIBinaryOp& ciBinaryOp )
35 Box& lhs= * ciBinaryOp.ArgsBegin;
36 Box& rhs= *(ciBinaryOp.ArgsBegin + 1);
39 if( ciBinaryOp.Operator !=
A_CHAR(
"?:") || !lhs.IsSameType(rhs) )
42 ALIB_DBG( ciBinaryOp.DbgCallbackName =
"elvis"; )
45 if( ciBinaryOp.LhsIsConst )
47 if( lhs.Call<FIsTrue>() )
48 ciBinaryOp.TypeOrValue= lhs;
52 if( ciBinaryOp.RhsIsConst )
53 ciBinaryOp.TypeOrValue= rhs;
55 ciBinaryOp.NonConstArgIsResult=
true;
61 ciBinaryOp.Callback = elvis;
62 ciBinaryOp.TypeOrValue= rhs;
decltype(std::declval< typename TFDecl::Signature >()(std::declval< Box & >(), std::declval< TArgs >()...)) Call(TArgs &&... args) const
expressions::CompilerPlugin CompilerPlugin
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
expressions::Compiler Compiler
Type alias in namespace alib.
ALIB_API ElvisOperator(Compiler &compiler)