/*============================================================================= This file is part of FLINT. FLINT is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. FLINT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FLINT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =============================================================================*/ /****************************************************************************** Copyright (C) 2013 Tom Bachmann ******************************************************************************/ // This file contains helpers recognising expression templates #ifndef CXX_EXPRESSION_TRAITS_H #define CXX_EXPRESSION_TRAITS_H #include "mp.h" #include "traits.h" namespace flint { namespace operations { // These are the operation tags the expression class creates directly. // unary operations struct immediate { }; struct negate { }; struct complement { }; // binary operations struct plus { }; struct minus { }; struct times { }; struct divided_by { }; struct modulo { }; struct shift { }; // left struct binary_and { }; struct binary_or { }; struct binary_xor { }; } // operations namespace traits { template struct is_expression : mp::false_ { }; template struct is_expression : mp::true_ { }; template struct _is_immediate_expr : _is_convertible< typename basetype::type::operation_t, operations::immediate > { }; // Compute if T is an expression, with operation "immediate" template struct is_immediate_expr : _is_immediate_expr { }; template struct is_immediate_expr > >::type> : mp::false_ { }; // Compute if T is an immediate expression, *or not an expression at all* template struct is_immediate : mp::or_ >, is_immediate_expr > { }; // Compute if T is a non-immediate expression template struct is_lazy_expr : mp::and_, mp::not_ > > { }; // Compute if Expr is an expression with prescribed evaluated type "T" template struct is_T_expr : mp::equal_types { }; template struct is_T_expr >::type> : false_ { }; // Decide if an expressing yielding From can be directly evaluated into To. // To be further specialised! template struct can_evaluate_into : mp::false_ { }; template struct can_evaluate_into : mp::true_ { }; // Decide if we should use temporary merging template struct use_temporary_merging : mp::true_ { }; } // traits } // flint #endif