Skip to content

Commit b7a990d

Browse files
Use C++20 (#6877)
1 parent 8306ed8 commit b7a990d

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Checks: >
5454
performance-*,
5555
-performance-noexcept-move-constructor,
5656
-performance-no-int-to-ptr,
57+
-performance-type-promotion-in-math-fn,
5758
readability-*,
5859
-readability-avoid-const-params-in-decls,
5960
-readability-braces-around-statements,
@@ -82,6 +83,7 @@ Checks: >
8283
-readability-make-member-function-const,
8384
-readability-redundant-string-init,
8485
-readability-non-const-parameter,
86+
-readability-container-contains,
8587
-readability-static-accessed-through-instance
8688
8789
WarningsAsErrors: '*'

.github/workflows/osrm-backend.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,36 @@ jobs:
396396
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
397397
echo "JOBS=$((`sysctl -n hw.ncpu` + 1))" >> $GITHUB_ENV
398398
fi
399+
# See: https://github.com/actions/toolkit/issues/946#issuecomment-1590016041
400+
# We need it to be able to access system folders while restoring cached Boost below
401+
- name: Give tar root ownership
402+
if: runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
403+
run: sudo chown root /bin/tar && sudo chmod u+s /bin/tar
404+
- name: Cache Boost
405+
if: runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
406+
id: cache-boost
407+
uses: actions/cache@v4
408+
with:
409+
path: |
410+
/usr/local/include/boost
411+
/usr/local/lib/libboost*
412+
key: v1-boost-${{ runner.os }}-${{ runner.arch }}-${{ matrix.runs-on }}
413+
restore-keys: |
414+
v1-boost-${{ runner.os }}-${{ runner.arch }}-${{ matrix.runs-on }}
399415
416+
- name: Install Boost
417+
if: steps.cache-boost.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
418+
run: |
419+
BOOST_VERSION="1.85.0"
420+
BOOST_VERSION_UNDERSCORE="${BOOST_VERSION//./_}"
421+
wget -q https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_UNDERSCORE}.tar.gz
422+
tar xzf boost_${BOOST_VERSION_UNDERSCORE}.tar.gz
423+
cd boost_${BOOST_VERSION_UNDERSCORE}
424+
sudo ./bootstrap.sh
425+
sudo ./b2 install
426+
cd ..
427+
sudo rm -rf boost_${BOOST_VERSION_UNDERSCORE}*
428+
400429
- name: Install dev dependencies
401430
run: |
402431
python3 -m pip install "conan<2.0.0" || python3 -m pip install "conan<2.0.0" --break-system-packages
@@ -417,7 +446,7 @@ jobs:
417446
# Linux dev packages
418447
if [ "${ENABLE_CONAN}" != "ON" ]; then
419448
sudo apt-get update -y
420-
sudo apt-get install -y libbz2-dev libxml2-dev libzip-dev liblua5.2-dev libboost-all-dev
449+
sudo apt-get install -y libbz2-dev libxml2-dev libzip-dev liblua5.2-dev
421450
if [[ "${CCOMPILER}" != clang-* ]]; then
422451
sudo apt-get install -y ${CXXCOMPILER}
423452
fi

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.18)
22

3-
set(CMAKE_CXX_STANDARD 17)
3+
set(CMAKE_CXX_STANDARD 20)
44
set(CMAKE_CXX_STANDARD_REQUIRED ON)
55
set(CMAKE_CXX_EXTENSIONS OFF)
66

cmake/warnings.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,9 @@ add_warning(switch-bool)
7878
add_warning(tautological-compare)
7979
add_warning(trampolines)
8080
# these warnings are not enabled by default
81-
# no_warning(name-of-warning)
81+
# no_warning(name-of-warning)
82+
no_warning(deprecated-comma-subscript)
83+
no_warning(comma-subscript)
84+
no_warning(ambiguous-reversed-operator)
85+
no_warning(restrict)
86+
no_warning(free-nonheap-object)

include/util/static_assert.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#ifndef OSRM_STATIC_ASSERT_HPP
22
#define OSRM_STATIC_ASSERT_HPP
33

4+
#include <iterator>
45
#include <type_traits>
56

67
namespace osrm::util
78
{
89

910
template <typename It, typename Value> inline void static_assert_iter_value()
1011
{
11-
using IterValueType = typename std::iterator_traits<It>::value_type;
12-
static_assert(std::is_same<IterValueType, Value>::value, "");
12+
static_assert(std::is_same_v<std::iter_value_t<It>, Value>, "");
1313
}
1414

1515
template <typename It, typename Category> inline void static_assert_iter_category()
1616
{
1717
using IterCategoryType = typename std::iterator_traits<It>::iterator_category;
18-
static_assert(std::is_base_of<Category, IterCategoryType>::value, "");
18+
static_assert(std::is_base_of_v<Category, IterCategoryType>, "");
1919
}
2020

2121
} // namespace osrm::util

0 commit comments

Comments
 (0)