$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] C++17 detection
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-09-11 00:28:57
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/