
27 Nov
2014
27 Nov
'14
10:12 p.m.
Olaf van der Spek <ml <at> vdspek.org> writes:
On Thu, Nov 27, 2014 at 5:08 PM, Marcel Raad <raad <at> teamviewer.com> wrote:
Has anyone reading this list every actually used std::map<boost::optional<T>, U>?
Yes, I frequently use that.
Could you describe how you're using it?
I use it to represent "none" in statistics code similar to the example in the Boost.Optional documentation (http://www.boost.org/doc/libs/master/libs /optional/doc/html/boost_optional/quick_st art/storage_in_containers.html). And I (perhaps mis-?)use it in configuration code to represent a default value so that I don't have to have an extra variable for each map: auto it = map.find(whatever); if(it != map.end()) return *it; else return map[boost::none];