xtensor
xtensor copied to clipboard
Some adapt(...) methods fail for clang-11 because size_type is not a member of std::allocator
In the standard library for clang-11, size_type
is no longer a member of std::allocator
. This is a difference from clang-10. Line 1765 of <memory>
versus line 1830 of <memory>
in the two libraries.
By my reading of the standard, although several members are removed for c++20, both size_type
and difference_type
should still be available. However, I am unsure about this interpretation.
In either case, this is causing several of the adapt
template methods to fail because they rely on the expression typename A::size_type
to deduce the type of a parameter.
I have been using the following patch in xadapt.hpp
to work around the issue:
template <class P>
struct default_allocator_for_ptr
{
using raw_type = std::allocator<std::remove_const_t<std::remove_pointer_t<std::remove_r\
eference_t<P>>>>;
struct enhanced_type : public raw_type {
using raw_type::raw_type;
using size_type = std::size_t;
using difference_typye = std::ptrdiff_t;
};
using type = enhanced_type;
};
I'd like someone with more expertise to weigh in on whether this is something that needs to be submitted as a bug to clang or if we need to develop a fix for xtensor.
Hi,
Sorry for the late reply. For me, this is definitely a bug of clang that should be fixed.