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

WIP: Bugfix: fix issue 145 compile on VS 2022 #146

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 4 additions & 3 deletions .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Main CI

on:
push:
branches: [main]
branches: [main, bugfix/fix-issue-145-compile-on-msvc-2022]
burnpanck marked this conversation as resolved.
Show resolved Hide resolved

jobs:
linux:
Expand Down Expand Up @@ -81,8 +81,9 @@ jobs:
matrix:
build_type: [Debug, Release]
sharedlibs: [OFF, ON]
std: [14, 17, 20]

runs-on: windows-2019
runs-on: windows-latest
burnpanck marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v2
Expand All @@ -91,7 +92,7 @@ jobs:
- name: Configure
shell: bash
working-directory: build/
run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019" -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}}
run: cmake $GITHUB_WORKSPACE -G"Visual Studio 17 2022" -DCMAKE_CXX_STANDARD=${{matrix.std}}  -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}}
- name: Build
working-directory: build/
run: cmake --build . --config ${{matrix.build_type}}
Expand Down
8 changes: 8 additions & 0 deletions include/foonathan/memory/allocator_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ namespace foonathan
FOONATHAN_REQUIRES(
(!std::is_base_of<allocator_storage, typename std::decay<Alloc>::type>::value))>
allocator_storage(Alloc&& alloc,
#if FOONATHAN_SFINAE_WORKAROUND
burnpanck marked this conversation as resolved.
Show resolved Hide resolved
FOONATHAN_SFINAE(new storage_policy(std::declval<Alloc&&>())))
burnpanck marked this conversation as resolved.
Show resolved Hide resolved
#else
FOONATHAN_SFINAE(new storage_policy(detail::forward<Alloc>(alloc))))
#endif
: storage_policy(detail::forward<Alloc>(alloc))
{
}
Expand All @@ -137,7 +141,11 @@ namespace foonathan
/// otherwise this constructor does not participate in overload resolution.
template <class OtherPolicy>
allocator_storage(const allocator_storage<OtherPolicy, Mutex>& other,
#if FOONATHAN_SFINAE_WORKAROUND
FOONATHAN_SFINAE(new storage_policy(std::declval<const allocator_storage<OtherPolicy, Mutex>&>().get_allocator())))
#else
FOONATHAN_SFINAE(new storage_policy(other.get_allocator())))
#endif
: storage_policy(other.get_allocator())
{
}
Expand Down
5 changes: 5 additions & 0 deletions include/foonathan/memory/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
#endif
#endif

// SFINAE workaround for MSVC 19.33
#ifndef FOONATHAN_SFINAE_WORKAROUND
burnpanck marked this conversation as resolved.
Show resolved Hide resolved
#define FOONATHAN_SFINAE_WORKAROUND 1
#endif

// log prefix
#define FOONATHAN_MEMORY_LOG_PREFIX "foonathan::memory"

Expand Down
8 changes: 8 additions & 0 deletions include/foonathan/memory/std_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ namespace foonathan
// MSVC seems to ignore access rights in decltype SFINAE below
// use this to prevent this constructor being chosen instead of move/copy for types inheriting from it
FOONATHAN_REQUIRES((!std::is_base_of<std_allocator, RawAlloc>::value))>
#if FOONATHAN_SFINAE_WORKAROUND
std_allocator(RawAlloc& alloc, FOONATHAN_SFINAE(alloc_reference(std::declval<RawAlloc&>()))) noexcept
#else
std_allocator(RawAlloc& alloc, FOONATHAN_SFINAE(alloc_reference(alloc))) noexcept
#endif
: alloc_reference(alloc)
{
}
Expand All @@ -149,7 +153,11 @@ namespace foonathan
// MSVC seems to ignore access rights in decltype SFINAE below
// use this to prevent this constructor being chosen instead of move/copy for types inheriting from it
FOONATHAN_REQUIRES((!std::is_base_of<std_allocator, RawAlloc>::value))>
#if FOONATHAN_SFINAE_WORKAROUND
std_allocator(const RawAlloc& alloc, FOONATHAN_SFINAE(alloc_reference(std::declval<const RawAlloc&>()))) noexcept
#else
std_allocator(const RawAlloc& alloc, FOONATHAN_SFINAE(alloc_reference(alloc))) noexcept
#endif
: alloc_reference(alloc)
{
}
Expand Down