Skip to content

Commit 4b53bea

Browse files
committed
Update for C++ 20 compatability
1 parent a17f3de commit 4b53bea

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

include/xtensor/xutils.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -793,12 +793,12 @@ namespace xt
793793
{
794794
using base_type = A;
795795
using value_type = typename A::value_type;
796-
using reference = typename A::reference;
797-
using const_reference = typename A::const_reference;
798-
using pointer = typename A::pointer;
799-
using const_pointer = typename A::const_pointer;
800-
using size_type = typename A::size_type;
801-
using difference_type = typename A::difference_type;
796+
using reference = value_type &;
797+
using const_reference = const value_type &;
798+
using pointer = typename std::allocator_traits<A>::pointer;
799+
using const_pointer = typename std::allocator_traits<A>::const_pointer;
800+
using size_type = typename std::allocator_traits<A>::size_type;
801+
using difference_type = typename std::allocator_traits<A>::difference_type;
802802

803803
tracking_allocator() = default;
804804

@@ -821,9 +821,13 @@ namespace xt
821821
return base_type::allocate(n);
822822
}
823823

824-
using base_type::construct;
825824
using base_type::deallocate;
825+
826+
// Construct and destroy are removed in --std=c++-20
827+
#if ((defined(__cplusplus) && __cplusplus < 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG < 202002L))
828+
using base_type::construct;
826829
using base_type::destroy;
830+
#endif
827831

828832
template <class U>
829833
struct rebind

test/test_xbuffer_adaptor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ namespace xt
7676
{
7777
public:
7878

79-
size_t* allocate(size_t n, const void* hint = 0)
79+
size_t* allocate(size_t n)
8080
{
81-
size_t* res = std::allocator<size_t>::allocate(n, hint);
81+
size_t* res = std::allocator<size_t>::allocate(n);
8282
// store the size into the result so we can
8383
// check if the size is correct when we deallocate.
8484
res[0] = n;

0 commit comments

Comments
 (0)