Boost logo

Boost :

Subject: Re: [boost] Cxx dual library
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2016-06-05 18:51:13


On 5 Jun 2016 at 17:53, Rob Stewart wrote:

> >namespace boost { namespace afio { namespace stl {
> >#if BOOST_AFIO_USING_BOOST_ATOMIC
> > namespace atomic = ::boost;
> >#else
> > namespace atomic = ::std;
> >#endif
> >
> >#if BOOST_AFIO_USING_BOOST_THREAD
> > namespace thread = ::boost;
> >#else
> > namespace thread = ::std;
> >#endif
> >
> >#if BOOST_AFIO_USING_BOOST_FILESYSTEM
> > namespace filesystem = ::boost;
> >#else
> > namespace filesystem = ::std;
> >#endif
> >} } }
> >
> >Now end user code must always write stl::<selector>::<class>. This I
> >think would work well enough.
>
> That also wasn't what he suggested.
>
> Vicente's idea was to import, say, std::thread or boost::thread into a
> new, common namespace. That is, foo::thread might refer to either of the
> others, based upon platform support or even an override macro.

I'm sorry, I really don't understand how this is different from the
code referred to above where boost::afio::stl::thread::thread would
be exactly what you say.

If you meant you want to import exclusively and solely the
boost::thread type alone, you could do:

namespace boost { namespace afio { namespace stl { typedef
::boost::thread thread; } } }

Is that what you meant?

If so, that pattern doesn't scale out. It doesn't support templates
under 03, and you rarely need to import just boost::thread, but
rather boost::thread and the other support stuff in the
<boost/thread.hpp> header all at once.

Which brings us full circle to the namespace binds I presented at C++
Now 2015 and are supplied in boost-lite, because I have a clang AST
parser grok the header file and extract out long lists of
"template<T> using symbol = ::whatever::symbol<T>" etc.

Edward I suppose could write out all that by hand, but why bother
when it can be automated?

For the record I think Edward's approach the best available approach
if you desire 98/03 compatibility. I don't believe it can be improved
upon.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



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