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

Update for C++ 20 compatibility #2774

Merged
merged 2 commits into from
Jul 2, 2024
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
18 changes: 11 additions & 7 deletions include/xtensor/xutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,12 @@ namespace xt
{
using base_type = A;
using value_type = typename A::value_type;
using reference = typename A::reference;
using const_reference = typename A::const_reference;
using pointer = typename A::pointer;
using const_pointer = typename A::const_pointer;
using size_type = typename A::size_type;
using difference_type = typename A::difference_type;
using reference = value_type&;
using const_reference = const value_type&;
using pointer = typename std::allocator_traits<A>::pointer;
using const_pointer = typename std::allocator_traits<A>::const_pointer;
using size_type = typename std::allocator_traits<A>::size_type;
using difference_type = typename std::allocator_traits<A>::difference_type;

tracking_allocator() = default;

Expand All @@ -821,9 +821,13 @@ namespace xt
return base_type::allocate(n);
}

using base_type::construct;
using base_type::deallocate;

// Construct and destroy are removed in --std=c++-20
#if ((defined(__cplusplus) && __cplusplus < 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG < 202002L))
using base_type::construct;
using base_type::destroy;
#endif

template <class U>
struct rebind
Expand Down
4 changes: 2 additions & 2 deletions test/test_xbuffer_adaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ namespace xt
{
public:

size_t* allocate(size_t n, const void* hint = 0)
size_t* allocate(size_t n)
{
size_t* res = std::allocator<size_t>::allocate(n, hint);
size_t* res = std::allocator<size_t>::allocate(n);
// store the size into the result so we can
// check if the size is correct when we deallocate.
res[0] = n;
Expand Down
Loading