diff --git a/.appveyor.yml b/.appveyor.yml index 2bc97fd..ccfb904 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,6 +3,7 @@ os: - Visual Studio 2017 build_script: + - git submodule update --init --recursive - mkdir build - cd build - cmake .. diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e6488b5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "cmake/tl-cmake"] + path = cmake/tl-cmake + url = https://github.com/TartanLlama/tl-cmake.git diff --git a/.travis.yml b/.travis.yml index 46eccb1..03842f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: cpp -dist: trusty +dist: xenial sudo: false matrix: @@ -98,7 +98,7 @@ matrix: addons: apt: sources: - - sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" + - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main" key_url: "http://apt.llvm.org/llvm-snapshot.gpg.key" - ubuntu-toolchain-r-test packages: @@ -109,7 +109,7 @@ matrix: addons: apt: sources: - - llvm-toolchain-trusty-4.0 + - llvm-toolchain-xenial-4.0 - ubuntu-toolchain-r-test packages: - clang++-4.0 @@ -119,7 +119,7 @@ matrix: addons: apt: sources: - - llvm-toolchain-trusty-5.0 + - llvm-toolchain-xenial-5.0 - ubuntu-toolchain-r-test packages: - clang++-5.0 @@ -129,7 +129,7 @@ matrix: addons: apt: sources: - - llvm-toolchain-trusty-6.0 + - llvm-toolchain-xenial-6.0 - ubuntu-toolchain-r-test packages: - clang++-6.0 @@ -212,7 +212,7 @@ matrix: addons: apt: sources: - - sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" + - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main" key_url: "http://apt.llvm.org/llvm-snapshot.gpg.key" - ubuntu-toolchain-r-test packages: @@ -223,7 +223,7 @@ matrix: addons: apt: sources: - - llvm-toolchain-trusty-4.0 + - llvm-toolchain-xenial-4.0 - ubuntu-toolchain-r-test packages: - clang++-4.0 @@ -233,7 +233,7 @@ matrix: addons: apt: sources: - - llvm-toolchain-trusty-5.0 + - llvm-toolchain-xenial-5.0 - ubuntu-toolchain-r-test packages: - clang++-5.0 @@ -243,7 +243,7 @@ matrix: addons: apt: sources: - - llvm-toolchain-trusty-6.0 + - llvm-toolchain-xenial-6.0 - ubuntu-toolchain-r-test packages: - clang++-6.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 46fbf1b..f25b0e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,23 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.11) -project(optional) +project(tl-optional VERSION 1.0.0 LANGUAGES CXX) option(OPTIONAL_ENABLE_TESTS "Enable tests." ON) -add_library(optional INTERFACE) -target_sources(optional INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tl/optional.hpp) -target_include_directories(optional INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tl) +include(FetchContent) +FetchContent_Declare( + tl_cmake + GIT_REPOSITORY https://github.com/TartanLlama/tl-cmake.git +) +FetchContent_GetProperties(tl_cmake) +if(NOT tl_cmake_POPULATED) + FetchContent_Populate(tl_cmake) + set(CMAKE_MODULE_PATH ${tl_cmake_SOURCE_DIR} ${CMAKE_MODULE_PATH}) +endif() +include(add-tl) + +tl_add_library(optional SOURCES + include/tl/optional.hpp) if(OPTIONAL_ENABLE_TESTS) # Prepare "Catch" library for other executables diff --git a/cmake/tl-optional-config.cmake.in b/cmake/tl-optional-config.cmake.in new file mode 100644 index 0000000..cc57bdf --- /dev/null +++ b/cmake/tl-optional-config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/tl-optional-targets.cmake") \ No newline at end of file diff --git a/tl/optional.hpp b/include/tl/optional.hpp similarity index 99% rename from tl/optional.hpp rename to include/tl/optional.hpp index 666ef4e..008b4b6 100644 --- a/tl/optional.hpp +++ b/include/tl/optional.hpp @@ -15,8 +15,9 @@ #ifndef TL_OPTIONAL_HPP #define TL_OPTIONAL_HPP -#define TL_OPTIONAL_VERSION_MAJOR 0 -#define TL_OPTIONAL_VERSION_MINOR 5 +#define TL_OPTIONAL_VERSION_MAJOR 1 +#define TL_OPTIONAL_VERSION_MINOR 0 +#define TL_OPTIONAL_VERSION_PATCH 0 #include #include @@ -137,13 +138,13 @@ struct conjunction : std::conditional, B>::type {}; #if defined(_LIBCPP_VERSION) && __cplusplus == 201103L -#define TL_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND +#define TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND #endif // In C++11 mode, there's an issue in libc++'s std::mem_fn // which results in a hard-error when using it in a noexcept expression // in some cases. This is a check to workaround the common failing case. -#ifdef TL_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND +#ifdef TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND template struct is_pointer_to_non_const_member_func : std::false_type{}; template struct is_pointer_to_non_const_member_func : std::true_type{}; @@ -166,7 +167,7 @@ template struct is_const_or_const_ref : std::true_type{}; // std::invoke from C++17 // https://stackoverflow.com/questions/38288042/c11-14-invoke-workaround template ::value && is_const_or_const_ref::value)>, #endif diff --git a/tests/assignment.cpp b/tests/assignment.cpp index 205ed7b..781be33 100644 --- a/tests/assignment.cpp +++ b/tests/assignment.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include TEST_CASE("Assignment value", "[assignment.value]") { tl::optional o1 = 42; diff --git a/tests/bases.cpp b/tests/bases.cpp index cff7819..7973b8c 100644 --- a/tests/bases.cpp +++ b/tests/bases.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include // Old versions of GCC don't have the correct trait names. Could fix them up if needs be. #if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 9 && \ diff --git a/tests/constexpr.cpp b/tests/constexpr.cpp index dc4db43..efd916c 100644 --- a/tests/constexpr.cpp +++ b/tests/constexpr.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include #define TOKENPASTE(x, y) x##y #define TOKENPASTE2(x, y) TOKENPASTE(x, y) diff --git a/tests/constructors.cpp b/tests/constructors.cpp index fc87a97..1c7a806 100644 --- a/tests/constructors.cpp +++ b/tests/constructors.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include #include struct foo { diff --git a/tests/emplace.cpp b/tests/emplace.cpp index 0a87983..feccd41 100644 --- a/tests/emplace.cpp +++ b/tests/emplace.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include #include #include diff --git a/tests/extensions.cpp b/tests/extensions.cpp index d97687e..a5d6352 100644 --- a/tests/extensions.cpp +++ b/tests/extensions.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include #include #define TOKENPASTE(x, y) x##y diff --git a/tests/hash.cpp b/tests/hash.cpp index 16437da..af0dff3 100644 --- a/tests/hash.cpp +++ b/tests/hash.cpp @@ -1,4 +1,4 @@ #include "catch.hpp" -#include "optional.hpp" +#include TEST_CASE("Hashing", "[hash]") {} diff --git a/tests/in_place.cpp b/tests/in_place.cpp index 07254e4..4fa87be 100644 --- a/tests/in_place.cpp +++ b/tests/in_place.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include #include #include diff --git a/tests/issues.cpp b/tests/issues.cpp index 387b083..d5672a3 100644 --- a/tests/issues.cpp +++ b/tests/issues.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include #include struct foo{ diff --git a/tests/make_optional.cpp b/tests/make_optional.cpp index ba44fd9..779ad52 100644 --- a/tests/make_optional.cpp +++ b/tests/make_optional.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include #include #include diff --git a/tests/noexcept.cpp b/tests/noexcept.cpp index b12fdea..0f5e368 100644 --- a/tests/noexcept.cpp +++ b/tests/noexcept.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include TEST_CASE("Noexcept", "[noexcept]") { tl::optional o1{4}; diff --git a/tests/nullopt.cpp b/tests/nullopt.cpp index 6340724..0ddd17b 100644 --- a/tests/nullopt.cpp +++ b/tests/nullopt.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include TEST_CASE("Nullopt", "[nullopt]") { tl::optional o1 = tl::nullopt; diff --git a/tests/observers.cpp b/tests/observers.cpp index 642b9f6..96db38f 100644 --- a/tests/observers.cpp +++ b/tests/observers.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include struct move_detector { move_detector() = default; diff --git a/tests/relops.cpp b/tests/relops.cpp index 2f388e7..4c06833 100644 --- a/tests/relops.cpp +++ b/tests/relops.cpp @@ -1,5 +1,5 @@ #include "catch.hpp" -#include "optional.hpp" +#include TEST_CASE("Relational ops", "[relops]") { tl::optional o1{4};