Commit 182a334b authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Add a wrapper header for std::(experimental::)optional

std::optional is a C++17 feature but it's implementation is present
in all modern C++14-capable compilers in library fundamentals TS.
This wrapper header includes the <optional> header where available
and falls back to <experimental/optional> otherwise, making the type
available as std::optional.
parent a24d7a6e
/*
Copyright (C) 2018 Daniel Vrátil <dvratil@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef AKOPTIONAL_H
#define AKOPTIONAL_H
#ifdef __has_include
#if __has_include(<optional>)
#include <optional>
#endif
#if !defined(__cpp_lib_optional) && __has_include(<experimental/optional>)
#include <experimental/optional>
namespace std { using namespace experimental; }
#else
#error Compiler does not support std::optional or std::experimental::optional
#endif
#else
#error Compiler does not support __has_include
#endif
#endif // AKOPTIONAL_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment