Skip to content

Commit

Permalink
Merge pull request #2774 from laramiel/master
Browse files Browse the repository at this point in the history
Update for C++ 20 compatibility
  • Loading branch information
JohanMabille authored Jul 2, 2024
2 parents edc67a3 + 5965f91 commit 474cd38
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 11 additions & 7 deletions include/xtensor/xutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,12 +807,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 @@ -835,9 +835,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

0 comments on commit 474cd38

Please sign in to comment.