Skip to content

Commit 474cd38

Browse files
authored
Merge pull request #2774 from laramiel/master
Update for C++ 20 compatibility
2 parents edc67a3 + 5965f91 commit 474cd38

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

include/xtensor/xutils.hpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -807,12 +807,12 @@ namespace xt
807807
{
808808
using base_type = A;
809809
using value_type = typename A::value_type;
810-
using reference = typename A::reference;
811-
using const_reference = typename A::const_reference;
812-
using pointer = typename A::pointer;
813-
using const_pointer = typename A::const_pointer;
814-
using size_type = typename A::size_type;
815-
using difference_type = typename A::difference_type;
810+
using reference = value_type&;
811+
using const_reference = const value_type&;
812+
using pointer = typename std::allocator_traits<A>::pointer;
813+
using const_pointer = typename std::allocator_traits<A>::const_pointer;
814+
using size_type = typename std::allocator_traits<A>::size_type;
815+
using difference_type = typename std::allocator_traits<A>::difference_type;
816816

817817
tracking_allocator() = default;
818818

@@ -835,9 +835,13 @@ namespace xt
835835
return base_type::allocate(n);
836836
}
837837

838-
using base_type::construct;
839838
using base_type::deallocate;
839+
840+
// Construct and destroy are removed in --std=c++-20
841+
#if ((defined(__cplusplus) && __cplusplus < 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG < 202002L))
842+
using base_type::construct;
840843
using base_type::destroy;
844+
#endif
841845

842846
template <class U>
843847
struct rebind

test/test_xbuffer_adaptor.cpp

+2-2
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)