Skip to content
Merged

Cpp17 #283

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 27 additions & 41 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,41 @@ defaults:
shell: bash -l {0}
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
name: '${{ matrix.sys.compiler }} ${{ matrix.sys.version }}'
strategy:
matrix:
sys:
- { compiler: 'gcc', version: '7' }
- { compiler: 'gcc', version: '8' }
- { compiler: 'gcc', version: '9' }
- { compiler: 'gcc', version: '10' }
- { compiler: 'gcc', version: '11' }
- { compiler: 'clang', version: '8' }
- { compiler: 'clang', version: '10' }
- { compiler: 'clang', version: '12' }
- { compiler: 'clang', version: '13' }
- { compiler: 'clang', version: '14' }
- { compiler: 'clang', version: '15' }
- { compiler: 'gcc', version: '12' }
- { compiler: 'gcc', version: '13' }
- { compiler: 'gcc', version: '14' }
- { compiler: 'clang', version: '17' }
- { compiler: 'clang', version: '18' }
- { compiler: 'clang', version: '19' }
- { compiler: 'clang', version: '20' }

steps:
- name: Setup compiler
if: ${{ matrix.sys.compiler == 'gcc' }}
run: |
GCC_VERSION=${{ matrix.sys.version }}
sudo apt-get update
sudo apt-get --no-install-suggests --no-install-recommends install g++-$GCC_VERSION
CC=gcc-$GCC_VERSION
echo "CC=$CC" >> $GITHUB_ENV
CXX=g++-$GCC_VERSION
echo "CXX=$CXX" >> $GITHUB_ENV
- name: Install GCC
if: matrix.sys.compiler == 'gcc'
uses: egor-tensin/setup-gcc@v1
with:
version: ${{matrix.sys.version}}
platform: x64

- name: Setup compiler
if: ${{ matrix.sys.compiler == 'clang' }}
- name: Install LLVM and Clang
if: matrix.sys.compiler == 'clang'
run: |
LLVM_VERSION=${{ matrix.sys.version }}
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1
if [[ $LLVM_VERSION -ge 13 ]]; then
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-$LLVM_VERSION main" || exit 1
else
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" || exit 1
fi || exit 1
sudo apt-get update || exit 1
sudo apt-get --no-install-suggests --no-install-recommends install clang-$LLVM_VERSION || exit 1
sudo apt-get --no-install-suggests --no-install-recommends install g++-9 g++-9-multilib || exit 1
sudo ln -s /usr/include/asm-generic /usr/include/asm
CC=clang-$LLVM_VERSION
echo "CC=$CC" >> $GITHUB_ENV
CXX=clang++-$LLVM_VERSION
echo "CXX=$CXX" >> $GITHUB_ENV
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{matrix.sys.version}}
sudo apt-get install -y clang-tools-${{matrix.sys.version}}
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{matrix.sys.version}} 200
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{matrix.sys.version}} 200
sudo update-alternatives --install /usr/bin/clang-scan-deps clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}} 200
sudo update-alternatives --set clang /usr/bin/clang-${{matrix.sys.version}}
sudo update-alternatives --set clang++ /usr/bin/clang++-${{matrix.sys.version}}
sudo update-alternatives --set clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}}

- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -70,10 +58,8 @@ jobs:
cache-environment: true

- name: Configure
env:
CC: ${{ env.CC }}
CXX: ${{ env.CXX }}
run: |
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
mkdir -p build
cd build
cmake .. -DBUILD_TESTS=ON \
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ jobs:
strategy:
matrix:
os:
- 11
- 12
- 13
- 14
- 15
runs-on: macos-${{ matrix.os }}
name: 'macos-${{ matrix.os }}'

Expand Down
33 changes: 6 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# The full license is in the file LICENSE, distributed with this software. #
############################################################################

cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.29)
project(xtl)

set(XTL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
Expand Down Expand Up @@ -37,7 +37,6 @@ endif()
# =====

set(XTL_HEADERS
${XTL_INCLUDE_DIR}/xtl/xany.hpp
${XTL_INCLUDE_DIR}/xtl/xbasic_fixed_string.hpp
${XTL_INCLUDE_DIR}/xtl/xbase64.hpp
${XTL_INCLUDE_DIR}/xtl/xclosure.hpp
Expand Down Expand Up @@ -67,8 +66,6 @@ set(XTL_HEADERS
${XTL_INCLUDE_DIR}/xtl/xsystem.hpp
${XTL_INCLUDE_DIR}/xtl/xtl_config.hpp
${XTL_INCLUDE_DIR}/xtl/xtype_traits.hpp
${XTL_INCLUDE_DIR}/xtl/xvariant.hpp
${XTL_INCLUDE_DIR}/xtl/xvariant_impl.hpp
${XTL_INCLUDE_DIR}/xtl/xvisitor.hpp
)

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

if(NOT (CMAKE_VERSION VERSION_LESS 3.15)) # CMake >= 3.15
set_target_properties(xtl
PROPERTIES
PUBLIC_HEADER "${XTL_HEADERS}")
endif()

target_compile_features(xtl INTERFACE cxx_std_14)
target_compile_features(xtl INTERFACE cxx_std_17)

option(BUILD_TESTS "xtl test suite" OFF)
option(DOWNLOAD_GTEST "build gtest from downloaded sources" OFF)
Expand All @@ -101,24 +96,14 @@ endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

if(CMAKE_VERSION VERSION_LESS 3.15) # CMake < 3.15
install(TARGETS xtl
EXPORT ${PROJECT_NAME}-targets)
else()
install(TARGETS xtl
EXPORT ${PROJECT_NAME}-targets
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
endif()

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

if(CMAKE_VERSION VERSION_LESS 3.15) # CMake < 3.15
install(FILES ${XTL_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xtl)
endif()

set(XTL_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}" CACHE
STRING "install path for xtlConfig.cmake")

Expand All @@ -132,16 +117,10 @@ configure_package_config_file(${PROJECT_NAME}Config.cmake.in
set(_XTL_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
unset(CMAKE_SIZEOF_VOID_P)
# ARCH_INDEPENDENT feature was introduced in cmake 3.14
if (${CMAKE_VERSION} VERSION_LESS "3.14.0")
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion)
else ()
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT)
endif ()
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT)
set(CMAKE_SIZEOF_VOID_P ${_XTL_CMAKE_SIZEOF_VOID_P})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
Expand Down
37 changes: 0 additions & 37 deletions docs/source/basic_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,6 @@
Basic types
===========

any
---

`xtl::any` is a backport of the C++17 class `std::any`. The class describes a
type-safe container for single values of any type:

.. code::

#include <iostream>
#include "xtl/xany.hpp"

xtl::any a = 1;
std::cout << a.type().name() << ": " << xtl::any_cast<int>(a) << std::endl;
// => i: 1

try
{
std::cout << xtl::any_cast<float>(a) << std::endl;
}
catch(const xtl::bad_any_cast& e)
{
std::cout << e.what() << std::endl;
}
// => bad any_cast

a.reset();
std::cout << std::boolalpha << a.empty() << std::endl;
// => true

The API of `xtl::any` is the same as that of `std::any`. Full documentation
can be found on `cppreference <https://en.cppreference.com/w/cpp/utility/any>`_.

xbasic_fixed_string
-------------------

Expand Down Expand Up @@ -108,8 +76,3 @@ xoptional

TODO

xvariant
--------

TODO

Loading