Boost logo

Boost :

Subject: Re: [boost] [variant] Opinion on boost::safe_get<> and default boost::get<> behavior
From: gast128 (gast128_at_[hidden])
Date: 2015-12-18 09:02:16


> Best,
> Vicente
>
> P.S. I don't think there will be too much uses of relaxed_get, but who
> know what C++ programmers use

Yes there are. The boost::get function is used by us to check if some data
source exist at runtime. It is somewhat like this, where a data source can
be in single datum mode or be buffered:

typedef boost::variant<int*, double*, std::vector<int>*> DataSource;

template <typename T>
class Sink
{
   bool Connect(const DataSource& crDataSource)
   {
      //check availability: try both m_p as m_pvec and if none is available
return false
   }

   T* m_p;
   std::vector<T*> m_pvec;
};

Sink<int> will compile, while Sink<double> not. Yes it can be rewritten with
an extra template argument, but that obfuscates code (no static_if in c++).
Anyway maybe we should drop Boost.Variant. It is also a compile time hog.


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