Boost logo

Boost :

Subject: Re: [boost] Cxx dual library
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2016-06-05 03:47:42


On 4 Jun 2016 at 21:28, Rob Stewart wrote:

> Edward, you've missed that Vicente doesn't see that importing either a
> Boost or a Standard Library solution, into a common namespace requires
> anything more of the user.
>
> The user would always use the new, common namespace name for something,
> regardless of its original namespace. For example, foo::x is the common
> name, but x may have been introduced into the foo namespace, by a using
> directive, from the boost or the std namespace.
>
> In the end, the user always includes the foo header and uses the foo
> name. There are no macros in the user's code. Both solutions select one
> implementation or the other. Yours refers to the namespace of the
> selected implementation with a macro, while his just uses namespace foo.

Do you mean an ultra-simplified form of what boost-lite does like
this:

namespace boost { namespace afio {
#if BOOST_AFIO_USING_BOOST_THREAD
  namespace stl11 = ::boost;
#else
  namespace stl11 = ::std;
#endif

#if BOOST_AFIO_USING_BOOST_FILESYSTEM
  namespace stl1z = ::boost;
#else
  namespace stl1z = ::std;
#endif
} }

This works, but it's quite ungranular e.g. how do you mash up
Boost.Thread with Std.Atomic? You could enable this at the cost of
extra typing imposed on the end user like this:

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.

I'll reiterate that boost-lite requires less typing on the end user
and is much safer and less error prone to use than the above scheme.
Still, the above works.

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