Boost logo

Boost :

Subject: Re: [boost] Re : BOOST_FOREACH like macro for map
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-10-20 19:04:08


AMDG

mobi phil wrote:
> I forgot to put in my question that I am looking for a macro and not
> template if possible, and for a solution as elegant as BOOST_FOREACH,
> where you have to code as less as possible. It not (only :) ) that I
> am lazy to write, but I think the resulting code would be easier to
> read.
>
> furthermore:
> 1. exception... throwing the exception removes the complexity of
> writing but introduces the complexity of exception (writing code +
> runtime).
>
> 2. pointer... use cases I would like to avoid pointers, as I have
> other constraints to work with const references.
>

Why? What's wrong with

if(const data_type* data = get_value(map, key)) {
    processResult(*data);
}

In Christ,
Steven Watanabe


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