Boost logo

Boost :

Subject: Re: [boost] C++17 detection
From: James E. King, III (jking_at_[hidden])
Date: 2017-09-11 01:11:28


I did the same thing with smart_ptr, allowing for a transition between
boost and std in the Apache Thrift project going from C++03 to C++11.
Unfortunately it was a bunch of trial and error as no macro seemed to cover
it completely.

https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/stdcxx.h

- Jim

On Sun, Sep 10, 2017 at 8:28 PM, Niall Douglas via Boost <
boost_at_[hidden]> wrote:

> On 10/09/2017 20:07, Glen Fernandes via Boost wrote:
> > On Sun, Sep 10, 2017 at 1:30 PM, Robert Ramey via Boost wrote:
> >> How do I get ready for C++17?
> >>
> >> I have a piece of code which requires C++14. I want to use something
> from
> >> C++17 but I also want my code to work now. So I have
> >>
> >> #if C++14 being used
> >> namespace std {
> >> // implement C++ function
> >> }
> >
> > Don't define those things inside namespace std. Instead:
> >
> > namespace boost {
> > namespace yours {
> > namespace detail {
> > #if /* C++17 thing available */
> > using std::thing;
> > #else
> > /* Define thing yourself */
> > #endif
> > } } }
> >
> > And then use boost::yours::detail::thing in your library.
>
> And here is an example of use of exactly that technique which uses
> std::optional if available with the current compiler's configuration,
> otherwise a conforming optional<T> implementation:
>
> https://github.com/ned14/quickcpplib/blob/master/include/optional.hpp
>
> Niall
>
> --
> ned Productions Limited Consulting
> http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/
> mailman/listinfo.cgi/boost
>


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