Skip to content

[libc++][test] Non-rebindable test_alloc in string.capacity/deallocate_size.pass.cpp #113609

Closed
@StephanTLavavej

Description

@StephanTLavavej

This test_alloc has a rebind struct, but not a rebinding constructor:

template <class T, class Sz>
struct test_alloc {
typedef Sz size_type;
typedef typename std::make_signed<Sz>::type difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef typename std::add_lvalue_reference<value_type>::type reference;
typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
template <class U>
struct rebind {
typedef test_alloc<U, Sz> other;
};
TEST_CONSTEXPR_CXX14 pointer allocate(size_type n, const void* = nullptr) {
allocated_ += n;
return std::allocator<value_type>().allocate(n);
}
TEST_CONSTEXPR_CXX14 void deallocate(pointer p, size_type s) {
allocated_ -= s;
std::allocator<value_type>().deallocate(p, s);
}
};

This fails to meet the allocator requirements. MSVC's STL rejects this because we attempt to rebind the allocator (to an internal "container proxy" type).

I observe other requirement deficiencies here (no comparison operators) but the rebinding one is the specific problem for us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.test-suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions