Boost logo

Boost Users :

Subject: [Boost-users] [Proto] Returns double
From: Hossein Haeri (powerprogman_at_[hidden])
Date: 2011-01-18 12:02:49


Dear all,
I am working in an application where I use Proto to evaluate an expression template like
_1 >> f >> g
to g(f(x)) once x is assigned to _1. (Please note that f and g are not necessarily functions -- they might be function objects too.) I am interested in putting a compile-time sanity check to ensure that the functions/function objects f and g do indeed return a double (or something convertible to it). For that, I wrote the following grammar which GCC 4.5.1 (Boost 1.42, MinGW32, WinXP, SP3) doesn't like, with the error messages being at the P.S. section:
struct EmtnRet2DblChk:
   or_
   <
     terminal<_>,
     and_
     <
       shift_right<EmtnRet2DblChk, terminal<_> >,
       if_
       <
         typename boost::is_convertible
         <
           typename boost::result_of<(_value(_right))(double)>::type,
           double
         >::type
       >
     >
   >
{};

(The above code starts in my line 81 and ends in my line 98.) Any idea please?
TIA,--Hossein
P.S.
Compiling: main.cpp
main.cpp:98:2: error: a cast to a type other than an integral or enumeration type cannot appear in a constant-expression

main.cpp:98:2: error: template argument 1 is invalid

main.cpp:92:22: error: wrong number of template arguments (1, should be 2)

/boost/type_traits/is_convertible.hpp:418:1: error: provided for 'template<class From, class To> struct boost::is_convertible'

main.cpp:90:21: error: template argument 1 is invalid

main.cpp:88:4: error: template argument 2 is invalid

85:3: error: template argument 2 is invalid

main.cpp:98:3: error: expected '{' before ';' token



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net