Skip to content

Commit

Permalink
Merge pull request #3872 from OSGeo/backport-3869-to-9.3
Browse files Browse the repository at this point in the history
[Backport 9.3] Fix build error with MSVC 2019 in /std:c++20 on NN_NO_CHECK()
  • Loading branch information
rouault authored Sep 2, 2023
2 parents e4a2a49 + e372d23 commit 9b553e2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ jobs:
mkdir %PROJ_BUILD%
cd %PROJ_BUILD%
set PROJ_DIR=%GITHUB_WORKSPACE%\proj_dir
cmake -DCMAKE_BUILD_TYPE="${{ env.BUILD_TYPE }}" -DBUILD_SHARED_LIBS="${{ env.BUILD_SHARED_LIBS }}" -DCMAKE_C_FLAGS="/WX" -DCMAKE_CXX_FLAGS="/WX" -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX="%PROJ_DIR%" -DPROJ_DB_CACHE_DIR=%PROJ_DB_CACHE_DIR% ..
# Not directly linked to BUILD_SHARED_LIBS, but a way to test different C++ standard versions
if "${{ env.BUILD_SHARED_LIBS }}"=="ON" (set EXTRA_CXX_FLAGS="/std:c++20")
cmake -DCMAKE_BUILD_TYPE="${{ env.BUILD_TYPE }}" -DBUILD_SHARED_LIBS="${{ env.BUILD_SHARED_LIBS }}" -DCMAKE_C_FLAGS="/WX" -DCMAKE_CXX_FLAGS="/WX %EXTRA_CXX_FLAGS%" -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX="%PROJ_DIR%" -DPROJ_DB_CACHE_DIR=%PROJ_DB_CACHE_DIR% ..
ninja -v
ninja install
dir %PROJ_DIR%\bin
Expand Down
22 changes: 19 additions & 3 deletions include/proj/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <map>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>

#ifndef NS_PROJ
Expand Down Expand Up @@ -203,10 +204,25 @@ using ::dropbox::oxygen::nn_static_pointer_cast;

template <typename T> using nn_shared_ptr = nn<std::shared_ptr<T>>;

// Possible implementation of C++14 std::remove_reference_t
// (cf https://en.cppreference.com/w/cpp/types/remove_cv)
template <class T>
using remove_reference_t = typename std::remove_reference<T>::type;

// Possible implementation of C++14 std::remove_cv_t
// (cf https://en.cppreference.com/w/cpp/types/remove_cv)
template <class T> using remove_cv_t = typename std::remove_cv<T>::type;

// Possible implementation of C++20 std::remove_cvref
// (cf https://en.cppreference.com/w/cpp/types/remove_cvref)
template <class T> struct remove_cvref {
typedef remove_cv_t<remove_reference_t<T>> type;
};

#define NN_NO_CHECK(p) \
::dropbox::oxygen::nn<typename std::remove_const< \
typename std::remove_reference<decltype(p)>::type>::type>( \
dropbox::oxygen::i_promise_i_checked_for_null, (p))
::dropbox::oxygen::nn< \
typename ::NS_PROJ::util::remove_cvref<decltype(p)>::type>( \
::dropbox::oxygen::i_promise_i_checked_for_null, (p))

//! @endcond

Expand Down

0 comments on commit 9b553e2

Please sign in to comment.