Skip to content

Commit

Permalink
Use C++20 (#6877)
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou committed May 25, 2024
1 parent 8306ed8 commit b7a990d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Checks: >
performance-*,
-performance-noexcept-move-constructor,
-performance-no-int-to-ptr,
-performance-type-promotion-in-math-fn,
readability-*,
-readability-avoid-const-params-in-decls,
-readability-braces-around-statements,
Expand Down Expand Up @@ -82,6 +83,7 @@ Checks: >
-readability-make-member-function-const,
-readability-redundant-string-init,
-readability-non-const-parameter,
-readability-container-contains,
-readability-static-accessed-through-instance
WarningsAsErrors: '*'
Expand Down
31 changes: 30 additions & 1 deletion .github/workflows/osrm-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,36 @@ jobs:
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
echo "JOBS=$((`sysctl -n hw.ncpu` + 1))" >> $GITHUB_ENV
fi
# See: https://github.com/actions/toolkit/issues/946#issuecomment-1590016041
# We need it to be able to access system folders while restoring cached Boost below
- name: Give tar root ownership
if: runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
run: sudo chown root /bin/tar && sudo chmod u+s /bin/tar
- name: Cache Boost
if: runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
id: cache-boost
uses: actions/cache@v4
with:
path: |
/usr/local/include/boost
/usr/local/lib/libboost*
key: v1-boost-${{ runner.os }}-${{ runner.arch }}-${{ matrix.runs-on }}
restore-keys: |
v1-boost-${{ runner.os }}-${{ runner.arch }}-${{ matrix.runs-on }}
- name: Install Boost
if: steps.cache-boost.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ENABLE_CONAN != 'ON'
run: |
BOOST_VERSION="1.85.0"
BOOST_VERSION_UNDERSCORE="${BOOST_VERSION//./_}"
wget -q https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_UNDERSCORE}.tar.gz
tar xzf boost_${BOOST_VERSION_UNDERSCORE}.tar.gz
cd boost_${BOOST_VERSION_UNDERSCORE}
sudo ./bootstrap.sh
sudo ./b2 install
cd ..
sudo rm -rf boost_${BOOST_VERSION_UNDERSCORE}*
- name: Install dev dependencies
run: |
python3 -m pip install "conan<2.0.0" || python3 -m pip install "conan<2.0.0" --break-system-packages
Expand All @@ -417,7 +446,7 @@ jobs:
# Linux dev packages
if [ "${ENABLE_CONAN}" != "ON" ]; then
sudo apt-get update -y
sudo apt-get install -y libbz2-dev libxml2-dev libzip-dev liblua5.2-dev libboost-all-dev
sudo apt-get install -y libbz2-dev libxml2-dev libzip-dev liblua5.2-dev
if [[ "${CCOMPILER}" != clang-* ]]; then
sudo apt-get install -y ${CXXCOMPILER}
fi
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
7 changes: 6 additions & 1 deletion cmake/warnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ add_warning(switch-bool)
add_warning(tautological-compare)
add_warning(trampolines)
# these warnings are not enabled by default
# no_warning(name-of-warning)
# no_warning(name-of-warning)
no_warning(deprecated-comma-subscript)
no_warning(comma-subscript)
no_warning(ambiguous-reversed-operator)
no_warning(restrict)
no_warning(free-nonheap-object)
6 changes: 3 additions & 3 deletions include/util/static_assert.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#ifndef OSRM_STATIC_ASSERT_HPP
#define OSRM_STATIC_ASSERT_HPP

#include <iterator>
#include <type_traits>

namespace osrm::util
{

template <typename It, typename Value> inline void static_assert_iter_value()
{
using IterValueType = typename std::iterator_traits<It>::value_type;
static_assert(std::is_same<IterValueType, Value>::value, "");
static_assert(std::is_same_v<std::iter_value_t<It>, Value>, "");
}

template <typename It, typename Category> inline void static_assert_iter_category()
{
using IterCategoryType = typename std::iterator_traits<It>::iterator_category;
static_assert(std::is_base_of<Category, IterCategoryType>::value, "");
static_assert(std::is_base_of_v<Category, IterCategoryType>, "");
}

} // namespace osrm::util
Expand Down

0 comments on commit b7a990d

Please sign in to comment.