Boost logo

Boost :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-09-24 06:40:37


<< cross-posted to clc++m in reply to http://tinyurl.com/ofj3 >>

Hi,

Problem: Without typeof, what is the result type of the expressions
(x + y), (x += y), (c ? x : y), (++x), (x++), etc. ?

Jaakko Jarvi and I are working on the Boost Lambda Library
(http://www.boost.org/libs/lambda/doc/index.html) and Phoenix
merger (http://www.boost.org/libs/spirit/phoenix/index.html).
Hopefully that will happen sometime in the near future. In an attempt
to do a better type deduction mechanism than what's provided in LL
(and Phoenix), I experimented with this idea:

(see [ http://tinyurl.com/ofqf ] )

In many cases, the result type of a binary expression is related to one of
its operands. The limited form of type deduction presented can detect
common relations if the result of a binary or unary operation, given arguments
x and y with types X and Y (respectively), is X, Y, X&, Y&, X*, Y*, X
const*, Y const*, bool, int, unsigned, double, container and iterator
elements (e.g the T, where X is: T[N], T*, vector<T>, map<T>,
vector<T>::iterator). More arguments/return type relationships can be
established if needed.

The (fully commented) code is just a prototype. The final version is slightly
different (some tweaks and bug-fixes here and there). Email me if you wish
to see the latest code.

Regards,

--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk