Boost logo

Boost :

Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-02-14 11:32:22


On Tue, Feb 14, 2012 at 5:07 PM, paul Fultz <pfultz2_at_[hidden]> wrote:
> One disadvantage of using a pointer instead of optional<T&> is when I write
> a functions to serach for an item in a map like this:
>
> template<class T, class Map>
> optional<T&> search_for(Map& m, T& key);
>
> Optional lets me call get_value_or() so I can return a value if it cant find the key,
>
> but using a pointer I can't do that so easily. However, another class such as

Why not?
get_value_or() for pointers seems trivial.

Olaf


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