Skip to content

Commit a70f60e

Browse files
authored
Merge pull request #283 from JohanMabille/cpp17
Cpp17
2 parents d11fb6b + fe2a720 commit a70f60e

20 files changed

+120
-4124
lines changed

.github/workflows/linux.yml

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,41 @@ defaults:
1212
shell: bash -l {0}
1313
jobs:
1414
build:
15-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-24.04
1616
name: '${{ matrix.sys.compiler }} ${{ matrix.sys.version }}'
1717
strategy:
1818
matrix:
1919
sys:
20-
- { compiler: 'gcc', version: '7' }
21-
- { compiler: 'gcc', version: '8' }
22-
- { compiler: 'gcc', version: '9' }
23-
- { compiler: 'gcc', version: '10' }
2420
- { compiler: 'gcc', version: '11' }
25-
- { compiler: 'clang', version: '8' }
26-
- { compiler: 'clang', version: '10' }
27-
- { compiler: 'clang', version: '12' }
28-
- { compiler: 'clang', version: '13' }
29-
- { compiler: 'clang', version: '14' }
30-
- { compiler: 'clang', version: '15' }
21+
- { compiler: 'gcc', version: '12' }
22+
- { compiler: 'gcc', version: '13' }
23+
- { compiler: 'gcc', version: '14' }
24+
- { compiler: 'clang', version: '17' }
25+
- { compiler: 'clang', version: '18' }
26+
- { compiler: 'clang', version: '19' }
27+
- { compiler: 'clang', version: '20' }
3128

3229
steps:
33-
- name: Setup compiler
34-
if: ${{ matrix.sys.compiler == 'gcc' }}
35-
run: |
36-
GCC_VERSION=${{ matrix.sys.version }}
37-
sudo apt-get update
38-
sudo apt-get --no-install-suggests --no-install-recommends install g++-$GCC_VERSION
39-
CC=gcc-$GCC_VERSION
40-
echo "CC=$CC" >> $GITHUB_ENV
41-
CXX=g++-$GCC_VERSION
42-
echo "CXX=$CXX" >> $GITHUB_ENV
30+
- name: Install GCC
31+
if: matrix.sys.compiler == 'gcc'
32+
uses: egor-tensin/setup-gcc@v1
33+
with:
34+
version: ${{matrix.sys.version}}
35+
platform: x64
4336

44-
- name: Setup compiler
45-
if: ${{ matrix.sys.compiler == 'clang' }}
37+
- name: Install LLVM and Clang
38+
if: matrix.sys.compiler == 'clang'
4639
run: |
47-
LLVM_VERSION=${{ matrix.sys.version }}
48-
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1
49-
if [[ $LLVM_VERSION -ge 13 ]]; then
50-
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-$LLVM_VERSION main" || exit 1
51-
else
52-
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" || exit 1
53-
fi || exit 1
54-
sudo apt-get update || exit 1
55-
sudo apt-get --no-install-suggests --no-install-recommends install clang-$LLVM_VERSION || exit 1
56-
sudo apt-get --no-install-suggests --no-install-recommends install g++-9 g++-9-multilib || exit 1
57-
sudo ln -s /usr/include/asm-generic /usr/include/asm
58-
CC=clang-$LLVM_VERSION
59-
echo "CC=$CC" >> $GITHUB_ENV
60-
CXX=clang++-$LLVM_VERSION
61-
echo "CXX=$CXX" >> $GITHUB_ENV
40+
wget https://apt.llvm.org/llvm.sh
41+
chmod +x llvm.sh
42+
sudo ./llvm.sh ${{matrix.sys.version}}
43+
sudo apt-get install -y clang-tools-${{matrix.sys.version}}
44+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{matrix.sys.version}} 200
45+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{matrix.sys.version}} 200
46+
sudo update-alternatives --install /usr/bin/clang-scan-deps clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}} 200
47+
sudo update-alternatives --set clang /usr/bin/clang-${{matrix.sys.version}}
48+
sudo update-alternatives --set clang++ /usr/bin/clang++-${{matrix.sys.version}}
49+
sudo update-alternatives --set clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}}
6250
6351
- name: Checkout code
6452
uses: actions/checkout@v3
@@ -70,10 +58,8 @@ jobs:
7058
cache-environment: true
7159

7260
- name: Configure
73-
env:
74-
CC: ${{ env.CC }}
75-
CXX: ${{ env.CXX }}
7661
run: |
62+
if [[ "${{matrix.sys.compiler}}" = "gcc" ]]; then export CC=gcc-${{matrix.sys.version}}; export CXX=g++-${{matrix.sys.version}}; else export CC=clang; export CXX=clang++; fi
7763
mkdir -p build
7864
cd build
7965
cmake .. -DBUILD_TESTS=ON \

.github/workflows/osx.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ jobs:
1212
strategy:
1313
matrix:
1414
os:
15-
- 11
16-
- 12
15+
- 13
16+
- 14
17+
- 15
1718
runs-on: macos-${{ matrix.os }}
1819
name: 'macos-${{ matrix.os }}'
1920

CMakeLists.txt

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# The full license is in the file LICENSE, distributed with this software. #
88
############################################################################
99

10-
cmake_minimum_required(VERSION 3.5)
10+
cmake_minimum_required(VERSION 3.29)
1111
project(xtl)
1212

1313
set(XTL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
@@ -37,7 +37,6 @@ endif()
3737
# =====
3838

3939
set(XTL_HEADERS
40-
${XTL_INCLUDE_DIR}/xtl/xany.hpp
4140
${XTL_INCLUDE_DIR}/xtl/xbasic_fixed_string.hpp
4241
${XTL_INCLUDE_DIR}/xtl/xbase64.hpp
4342
${XTL_INCLUDE_DIR}/xtl/xclosure.hpp
@@ -67,8 +66,6 @@ set(XTL_HEADERS
6766
${XTL_INCLUDE_DIR}/xtl/xsystem.hpp
6867
${XTL_INCLUDE_DIR}/xtl/xtl_config.hpp
6968
${XTL_INCLUDE_DIR}/xtl/xtype_traits.hpp
70-
${XTL_INCLUDE_DIR}/xtl/xvariant.hpp
71-
${XTL_INCLUDE_DIR}/xtl/xvariant_impl.hpp
7269
${XTL_INCLUDE_DIR}/xtl/xvisitor.hpp
7370
)
7471

@@ -78,13 +75,11 @@ target_include_directories(xtl INTERFACE
7875
$<BUILD_INTERFACE:${XTL_INCLUDE_DIR}>
7976
$<INSTALL_INTERFACE:include>)
8077

81-
if(NOT (CMAKE_VERSION VERSION_LESS 3.15)) # CMake >= 3.15
8278
set_target_properties(xtl
8379
PROPERTIES
8480
PUBLIC_HEADER "${XTL_HEADERS}")
85-
endif()
8681

87-
target_compile_features(xtl INTERFACE cxx_std_14)
82+
target_compile_features(xtl INTERFACE cxx_std_17)
8883

8984
option(BUILD_TESTS "xtl test suite" OFF)
9085
option(DOWNLOAD_GTEST "build gtest from downloaded sources" OFF)
@@ -101,24 +96,14 @@ endif()
10196
include(GNUInstallDirs)
10297
include(CMakePackageConfigHelpers)
10398

104-
if(CMAKE_VERSION VERSION_LESS 3.15) # CMake < 3.15
105-
install(TARGETS xtl
106-
EXPORT ${PROJECT_NAME}-targets)
107-
else()
10899
install(TARGETS xtl
109100
EXPORT ${PROJECT_NAME}-targets
110101
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
111-
endif()
112102

113103
# Makes the project importable from the build directory
114104
export(EXPORT ${PROJECT_NAME}-targets
115105
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
116106

117-
if(CMAKE_VERSION VERSION_LESS 3.15) # CMake < 3.15
118-
install(FILES ${XTL_HEADERS}
119-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xtl)
120-
endif()
121-
122107
set(XTL_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}" CACHE
123108
STRING "install path for xtlConfig.cmake")
124109

@@ -132,16 +117,10 @@ configure_package_config_file(${PROJECT_NAME}Config.cmake.in
132117
set(_XTL_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
133118
unset(CMAKE_SIZEOF_VOID_P)
134119
# ARCH_INDEPENDENT feature was introduced in cmake 3.14
135-
if (${CMAKE_VERSION} VERSION_LESS "3.14.0")
136-
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
137-
VERSION ${${PROJECT_NAME}_VERSION}
138-
COMPATIBILITY AnyNewerVersion)
139-
else ()
140-
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
141-
VERSION ${${PROJECT_NAME}_VERSION}
142-
COMPATIBILITY AnyNewerVersion
143-
ARCH_INDEPENDENT)
144-
endif ()
120+
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
121+
VERSION ${${PROJECT_NAME}_VERSION}
122+
COMPATIBILITY AnyNewerVersion
123+
ARCH_INDEPENDENT)
145124
set(CMAKE_SIZEOF_VOID_P ${_XTL_CMAKE_SIZEOF_VOID_P})
146125
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
147126
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake

docs/source/basic_types.rst

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,6 @@
77
Basic types
88
===========
99

10-
any
11-
---
12-
13-
`xtl::any` is a backport of the C++17 class `std::any`. The class describes a
14-
type-safe container for single values of any type:
15-
16-
.. code::
17-
18-
#include <iostream>
19-
#include "xtl/xany.hpp"
20-
21-
xtl::any a = 1;
22-
std::cout << a.type().name() << ": " << xtl::any_cast<int>(a) << std::endl;
23-
// => i: 1
24-
25-
try
26-
{
27-
std::cout << xtl::any_cast<float>(a) << std::endl;
28-
}
29-
catch(const xtl::bad_any_cast& e)
30-
{
31-
std::cout << e.what() << std::endl;
32-
}
33-
// => bad any_cast
34-
35-
a.reset();
36-
std::cout << std::boolalpha << a.empty() << std::endl;
37-
// => true
38-
39-
The API of `xtl::any` is the same as that of `std::any`. Full documentation
40-
can be found on `cppreference <https://en.cppreference.com/w/cpp/utility/any>`_.
41-
4210
xbasic_fixed_string
4311
-------------------
4412

@@ -108,8 +76,3 @@ xoptional
10876

10977
TODO
11078

111-
xvariant
112-
--------
113-
114-
TODO
115-

0 commit comments

Comments
 (0)