15namespace alib {
namespace expressions {
namespace plugins {
23Box elvis( Scope&, ArgIterator arg, ArgIterator )
25 return (*arg).
Call<FIsTrue>() ? *arg : *(arg + 1);
30bool ElvisOperator::TryCompilation( CIBinaryOp& ciBinaryOp )
32 Box& lhs= * ciBinaryOp.ArgsBegin;
33 Box& rhs= *(ciBinaryOp.ArgsBegin + 1);
36 if( ciBinaryOp.Operator !=
A_CHAR(
"?:") || !lhs.IsSameType(rhs) )
39 ALIB_DBG( ciBinaryOp.DbgCallbackName =
"elvis"; )
42 if( ciBinaryOp.LhsIsConst )
44 if( lhs.Call<FIsTrue>() )
45 ciBinaryOp.TypeOrValue= lhs;
49 if( ciBinaryOp.RhsIsConst )
50 ciBinaryOp.TypeOrValue= rhs;
52 ciBinaryOp.NonConstArgIsResult= true;
58 ciBinaryOp.Callback = elvis;
59 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)