summaryrefslogtreecommitdiff
path: root/include/o3tl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-02-21 07:26:06 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-02-21 14:50:28 +0100
commit9ad252b2e79576119c2d733a1a45fdd9e9f83140 (patch)
tree87fee16145d457b6799a05c389d85270476f7f35 /include/o3tl
parent3aca35f1505fa552eaa316a2d47a60ef52646525 (diff)
Drop o3tl::optional wrapper
...now that macOS builds are guaranteed to have std::optional since 358146bbbd1b9775c12770fb5e497b6ec5adfc51 "Bump macOS build baseline to Xcode 11.3 and macOS 10.14.4". The change is done mostly mechanically with > for i in $(git grep -Fl optional); do > sed -i -e 's:<o3tl/optional\.hxx>\|\"o3tl/optional\.hxx\":<optional>:' \ > -e 's/\<o3tl::optional\>/std::optional/g' \ > -e 's/\<o3tl::make_optional\>/std::make_optional/g' "$i" > done > for i in $(git grep -Flw o3tl::nullopt); do > sed -i -e 's/\<o3tl::nullopt\>/std::nullopt/g' "$i" > done (though that causes some of the resulting #include <optional> to appear at different places relative to other includes than if they had been added manually), plus a few manual modifications: * adapt bin/find-unneeded-includes * adapt desktop/IwyuFilter_desktop.yaml * remove include/o3tl/optional.hxx * quote resulting "<"/">" as "&lt;"/"&gt;" in officecfg/registry/cppheader.xsl * and then solenv/clang-format/reformat-formatted-files Change-Id: I68833d9f7945e57aa2bc703349cbc5a56b342273 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89165 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/o3tl')
-rw-r--r--include/o3tl/any.hxx38
-rw-r--r--include/o3tl/optional.hxx46
2 files changed, 19 insertions, 65 deletions
diff --git a/include/o3tl/any.hxx b/include/o3tl/any.hxx
index b4d9e5272fc5..0acccff6439f 100644
--- a/include/o3tl/any.hxx
+++ b/include/o3tl/any.hxx
@@ -16,7 +16,7 @@
#include <type_traits>
#include <utility>
-#include <o3tl/optional.hxx>
+#include <optional>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/RuntimeException.hpp>
@@ -36,37 +36,37 @@ namespace detail {
struct Void {};
template<typename T> struct Optional { using type = T const *; };
-template<> struct Optional<void> { using type = o3tl::optional<Void const>; };
-template<> struct Optional<bool> { using type = o3tl::optional<bool const>; };
+template<> struct Optional<void> { using type = std::optional<Void const>; };
+template<> struct Optional<bool> { using type = std::optional<bool const>; };
template<> struct Optional<sal_Int8> {
- using type = o3tl::optional<sal_Int8 const>;
+ using type = std::optional<sal_Int8 const>;
};
template<> struct Optional<sal_Int16> {
- using type = o3tl::optional<sal_Int16 const>;
+ using type = std::optional<sal_Int16 const>;
};
template<> struct Optional<sal_uInt16> {
- using type = o3tl::optional<sal_uInt16 const>;
+ using type = std::optional<sal_uInt16 const>;
};
template<> struct Optional<sal_Int32> {
- using type = o3tl::optional<sal_Int32 const>;
+ using type = std::optional<sal_Int32 const>;
};
template<> struct Optional<sal_uInt32> {
- using type = o3tl::optional<sal_uInt32 const>;
+ using type = std::optional<sal_uInt32 const>;
};
template<> struct Optional<sal_Int64> {
- using type = o3tl::optional<sal_Int64 const>;
+ using type = std::optional<sal_Int64 const>;
};
template<> struct Optional<sal_uInt64> {
- using type = o3tl::optional<sal_uInt64 const>;
+ using type = std::optional<sal_uInt64 const>;
};
template<> struct Optional<float> {
- using type = o3tl::optional<float const>;
+ using type = std::optional<float const>;
};
template<> struct Optional<double> {
- using type = o3tl::optional<double const>;
+ using type = std::optional<double const>;
};
template<typename T> struct Optional<css::uno::Reference<T>> {
- using type = o3tl::optional<css::uno::Reference<T> const>;
+ using type = std::optional<css::uno::Reference<T> const>;
};
template<> struct Optional<css::uno::Reference<css::uno::XInterface>> {
using type = css::uno::Reference<css::uno::XInterface> const *;
@@ -85,12 +85,12 @@ template<typename T> struct IsUnoSequenceType<cppu::UnoSequenceType<T>>:
std::true_type
{};
-template<typename T> inline o3tl::optional<T const> tryGetConverted(
+template<typename T> inline std::optional<T const> tryGetConverted(
css::uno::Any const & any)
{
T v;
return (any >>= v)
- ? o3tl::optional<T const>(std::move(v)) : o3tl::optional<T const>();
+ ? std::optional<T const>(std::move(v)) : std::optional<T const>();
}
}
@@ -105,7 +105,7 @@ template<typename T> inline o3tl::optional<T const> tryGetConverted(
proxy is positive. For a positive proxy P representing a value of requested
type T, for any T other than void, the expression *P yields that value of
type T. (Technically, the proxy is either a plain pointer or a
- o3tl::optional, depending on whether a plain pointer into the given Any can
+ std::optional, depending on whether a plain pointer into the given Any can
be returned for the specified type.)
@attention A proxy returned from this function must not outlive the
@@ -124,7 +124,7 @@ template<typename T> inline o3tl::optional<T const> tryGetConverted(
@note Ideally this would be a public member function of css::uno::Any (at
least conditional on LIBO_INTERNAL_ONLY, as it requires C++11). However, as
std::optional (which would be needed to implement the proxies) is only
- available since C++14, we need to use o3tl::optional for now. But To not
+ available since C++14, we need to use std::optional for now. But To not
make every entity that includes <com/sun/star/uno/Any.hxx> depend on
boost_headers, keep this here for now.
@@ -156,8 +156,8 @@ template<> inline detail::Optional<void>::type tryAccess<void>(
css::uno::Any const & any)
{
return any.hasValue()
- ? o3tl::optional<detail::Void const>()
- : o3tl::optional<detail::Void const>(detail::Void());
+ ? std::optional<detail::Void const>()
+ : std::optional<detail::Void const>(detail::Void());
}
template<> inline detail::Optional<bool>::type tryAccess<bool>(
diff --git a/include/o3tl/optional.hxx b/include/o3tl/optional.hxx
deleted file mode 100644
index 524818230e3e..000000000000
--- a/include/o3tl/optional.hxx
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-// A wrapper selecting either std::optional or boost::optional as a fallback for Xcode < 10. To be
-// removed once std::optional is available everywhere.
-
-#ifndef INCLUDED_O3TL_OPTIONAL_HXX
-#define INCLUDED_O3TL_OPTIONAL_HXX
-
-#include <sal/config.h>
-
-#if defined __APPLE__ && !__has_include(<optional>)
-
-#include <boost/none.hpp>
-#include <boost/optional.hpp>
-
-namespace o3tl
-{
-using boost::make_optional;
-using boost::optional;
-
-inline auto const nullopt = boost::none;
-}
-
-#else
-
-#include <optional>
-
-namespace o3tl
-{
-using std::make_optional;
-using std::nullopt;
-using std::optional;
-}
-
-#endif
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */