Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build error with MSVC 2019 in /std:c++20 on NN_NO_CHECK() #3869

Merged
merged 2 commits into from
Sep 1, 2023
Merged
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
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
Loading