mirror of https://github.com/mosra/magnum.git
Browse Source
This was a dirty mess. Good riddance. Also removing the include from the header now, as it has a forward declaration and thus is not needed.pull/374/head
30 changed files with 27 additions and 312 deletions
@ -1,32 +0,0 @@
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a |
||||
# copy of this software and associated documentation files (the "Software"), |
||||
# to deal in the Software without restriction, including without limitation |
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
# and/or sell copies of the Software, and to permit persons to whom the |
||||
# Software is furnished to do so, subject to the following conditions: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
# DEALINGS IN THE SOFTWARE. |
||||
# |
||||
|
||||
if(MAGNUM_BUILD_DEPRECATED) |
||||
install(FILES optional.hpp OptionalWrapper.h DESTINATION ${MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR}/Optional) |
||||
endif() |
||||
|
||||
if(BUILD_TESTS) |
||||
add_subdirectory(Test) |
||||
endif() |
||||
@ -1,68 +0,0 @@
|
||||
#ifndef MagnumExternal_Optional_OptionalWrapper_hpp |
||||
#define MagnumExternal_Optional_OptionalWrapper_hpp |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#if !defined(Corrade_Containers_Optional_h) || !defined(Corrade_Utility_Macros_h) || !defined(MAGNUM_BUILD_DEPRECATED) |
||||
#error This file is not meant to be used directly. |
||||
#endif |
||||
|
||||
/* Cover your eyes. This will hurt. And wash your hands after. */ |
||||
#ifdef MAGNUM_BUILD_DEPRECATED |
||||
#ifdef __has_include |
||||
#if __has_include(<optional>) && CORRADE_CXX_STANDARD >= 201703L |
||||
#define _MAGNUM_HAS_STD_OPTIONAL |
||||
#include <optional> |
||||
|
||||
namespace Corrade { namespace Containers { namespace Implementation { |
||||
template<class T> struct OptionalConverter<T, std::optional<T>> { |
||||
CORRADE_DEPRECATED("use Corrade::Containers::Optional instead") static std::optional<T> to(const Optional<T>& other) { |
||||
if(other) return std::optional<T>{*other}; |
||||
else return std::nullopt; |
||||
} |
||||
CORRADE_DEPRECATED("use Corrade::Containers::Optional instead") static std::optional<T> to(Optional<T>&& other) { |
||||
if(other) return std::optional<T>{std::move(*other)}; |
||||
else return std::nullopt; |
||||
} |
||||
}; |
||||
}}} |
||||
#endif |
||||
#endif |
||||
|
||||
#ifdef _MAGNUM_HAS_STD_OPTIONAL |
||||
#else |
||||
namespace std { |
||||
template<class T> using optional CORRADE_DEPRECATED_ALIAS("use Corrade::Containers::Optional instead") = Corrade::Containers::Optional<T>; |
||||
|
||||
constexpr CORRADE_DEPRECATED("use Corrade::Containers::NullOpt instead") Corrade::Containers::NullOptT nullopt{Corrade::Containers::NullOptT::Init{}}; |
||||
|
||||
template<class T> CORRADE_DEPRECATED("use Corrade::Containers::optional() instead") inline Corrade::Containers::Optional<typename std::decay<T>::type> make_optional(T&& value) { |
||||
return Corrade::Containers::Optional<typename std::decay<T>::type>{std::forward<T>(value)}; |
||||
} |
||||
} |
||||
#endif |
||||
#endif |
||||
|
||||
#endif |
||||
@ -1,47 +0,0 @@
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# Permission is hereby granted, free of charge, to any person obtaining a |
||||
# copy of this software and associated documentation files (the "Software"), |
||||
# to deal in the Software without restriction, including without limitation |
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
# and/or sell copies of the Software, and to permit persons to whom the |
||||
# Software is furnished to do so, subject to the following conditions: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
# DEALINGS IN THE SOFTWARE. |
||||
# |
||||
|
||||
corrade_add_test(StdOptionalTest StdOptionalTest.cpp) |
||||
target_include_directories(StdOptionalTest PRIVATE |
||||
${PROJECT_SOURCE_DIR}/src |
||||
${PROJECT_BINARY_DIR}/src) |
||||
set_target_properties(StdOptionalTest PROPERTIES FOLDER "MagnumExternal/Optional/Test") |
||||
|
||||
# Try using C++17 on newer compilers. Can't use VERSION_GREATER_EQUAL because |
||||
# older CMake doesn't support these. No idea how to detect libc++ presence on |
||||
# non-Apple platforms (or even version), so I'm giving up there, testing just |
||||
# elsewhere. |
||||
# |
||||
# Compiler versions where std::optional is supported: |
||||
# MSVC 2017 (trust me, I know) |
||||
# GCC libstdc++ 7.1 (see https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#table.cxx17_status) |
||||
# libc++ 4.0 (see https://launchpad.net/ubuntu/+source/libc++) |
||||
# Apple Clang 9.0 correspons to LLVM 4.0 (see https://gist.github.com/yamaya/2924292#gistcomment-2289472) |
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.1") OR |
||||
#(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.0") OR |
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0") OR |
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.10")) |
||||
set_target_properties(StdOptionalTest PROPERTIES CORRADE_CXX_STANDARD 17) |
||||
endif() |
||||
@ -1,111 +0,0 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
/* Needs to be here otherwise the deprecation warning inside OptionalConverter
|
||||
is not ignored */ |
||||
#ifdef _MSC_VER |
||||
#pragma warning(push) |
||||
#pragma warning(disable: 4996) |
||||
#endif |
||||
|
||||
#include <memory> |
||||
#include <Corrade/Containers/Optional.h> |
||||
#include <Corrade/TestSuite/Tester.h> |
||||
|
||||
#include "Magnum/Magnum.h" |
||||
#include "MagnumExternal/Optional/OptionalWrapper.h" |
||||
|
||||
namespace Magnum { namespace Test { namespace { |
||||
|
||||
struct StdOptionalTest: TestSuite::Tester { |
||||
explicit StdOptionalTest(); |
||||
|
||||
void conversion(); |
||||
}; |
||||
|
||||
StdOptionalTest::StdOptionalTest() { |
||||
addTests({&StdOptionalTest::conversion}); |
||||
} |
||||
|
||||
#ifdef __GNUC__ |
||||
#pragma GCC diagnostic push |
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
||||
#endif |
||||
void StdOptionalTest::conversion() { |
||||
Debug{} << "Using C++ version" << CORRADE_CXX_STANDARD; |
||||
#ifdef __has_include |
||||
Debug{} << "__has_include is supported"; |
||||
#if __has_include(<optional>) |
||||
Debug{} << "<optional> header is present"; |
||||
#else |
||||
Debug{} << "<optional> header is not present"; |
||||
#endif |
||||
#if __has_include(<experimental/optional>) |
||||
Debug{} << "<experimental/optional> header is present"; |
||||
#else |
||||
Debug{} << "<experimental/optional> header is not present"; |
||||
#endif |
||||
#else |
||||
Debug{} << "__has_include is not supported"; |
||||
#endif |
||||
#ifdef _MAGNUM_HAS_STD_OPTIONAL |
||||
Debug{} << "Using a conversion to std::optional, C++17 should be present"; |
||||
CORRADE_VERIFY(CORRADE_CXX_STANDARD >= 201703L); |
||||
#else |
||||
Debug{} << "Using a typedef to std::optional, C++17 should not be present"; |
||||
{ |
||||
#ifdef CORRADE_TARGET_APPLE |
||||
CORRADE_EXPECT_FAIL_IF(CORRADE_CXX_STANDARD >= 201703L, |
||||
"Even Xcode 9.3 beta doesn't have the <optional> header, only <experimental/optional>, thus a typedef is used."); |
||||
#endif |
||||
CORRADE_VERIFY(CORRADE_CXX_STANDARD < 201703L); |
||||
} |
||||
#endif |
||||
|
||||
Containers::Optional<int> a{5}; |
||||
Containers::Optional<int> b; |
||||
|
||||
std::optional<int> sa = a; |
||||
CORRADE_COMPARE(*sa, 5); |
||||
std::optional<int> sb = b; |
||||
CORRADE_VERIFY(!sb); |
||||
std::optional<int> empty = std::nullopt; |
||||
CORRADE_VERIFY(!empty); |
||||
|
||||
Containers::Optional<std::unique_ptr<int>> c{std::unique_ptr<int>{new int{7}}}; |
||||
std::optional<std::unique_ptr<int>> sc = std::move(c); |
||||
CORRADE_COMPARE(**sc, 7); |
||||
} |
||||
#ifdef __GNUC__ |
||||
#pragma GCC diagnostic pop |
||||
#endif |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Test::StdOptionalTest) |
||||
|
||||
#ifdef _MSC_VER |
||||
#pragma warning(pop) |
||||
#endif |
||||
@ -1,39 +0,0 @@
|
||||
#ifndef MagnumExternal_Optional_optional_hpp |
||||
#define MagnumExternal_Optional_optional_hpp |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <Corrade/Containers/Optional.h> |
||||
#include <Corrade/Utility/Macros.h> |
||||
|
||||
#include "Magnum/configure.h" |
||||
|
||||
/* This file is here only to preserve backwards compatibility. It issues a
|
||||
deprecation warning and includes the Optional wrapper header which itself |
||||
doesn't issue a deprecation warning, as it is included from internal code. */ |
||||
CORRADE_DEPRECATED_FILE("use <Corrade/Containers/Optional.h> instead") |
||||
#include "OptionalWrapper.h" |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue