Final bit for LWG #2263; test different allocator pointer types. Note that libc++ already does the right thing here; I've just added tests to ensure that it stays this way.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@203539 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6dbaaa99a8
commit
3ebf26f90d
@ -0,0 +1,116 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include <scoped_allocator>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
// #include <memory>
|
||||||
|
//
|
||||||
|
// template <class Alloc>
|
||||||
|
// struct allocator_traits
|
||||||
|
// {
|
||||||
|
// typedef Alloc allocator_type;
|
||||||
|
// typedef typename allocator_type::value_type
|
||||||
|
// value_type;
|
||||||
|
//
|
||||||
|
// typedef Alloc::pointer | value_type* pointer;
|
||||||
|
// typedef Alloc::const_pointer
|
||||||
|
// | pointer_traits<pointer>::rebind<const value_type>
|
||||||
|
// const_pointer;
|
||||||
|
// typedef Alloc::void_pointer
|
||||||
|
// | pointer_traits<pointer>::rebind<void>
|
||||||
|
// void_pointer;
|
||||||
|
// typedef Alloc::const_void_pointer
|
||||||
|
// | pointer_traits<pointer>::rebind<const void>
|
||||||
|
// const_void_pointer;
|
||||||
|
|
||||||
|
template <typename Alloc>
|
||||||
|
void test_pointer()
|
||||||
|
{
|
||||||
|
typename std::allocator_traits<Alloc>::pointer vp;
|
||||||
|
typename std::allocator_traits<Alloc>::const_pointer cvp;
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Alloc>
|
||||||
|
void test_void_pointer()
|
||||||
|
{
|
||||||
|
typename std::allocator_traits<Alloc>::void_pointer vp;
|
||||||
|
typename std::allocator_traits<Alloc>::const_void_pointer cvp;
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Foo { int x; };
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
|
||||||
|
test_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
|
||||||
|
test_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();
|
||||||
|
|
||||||
|
test_void_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
|
||||||
|
test_void_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
|
||||||
|
test_void_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int main() {}
|
||||||
|
#endif
|
@ -0,0 +1,116 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
// #include <memory>
|
||||||
|
//
|
||||||
|
// template <class Alloc>
|
||||||
|
// struct allocator_traits
|
||||||
|
// {
|
||||||
|
// typedef Alloc allocator_type;
|
||||||
|
// typedef typename allocator_type::value_type
|
||||||
|
// value_type;
|
||||||
|
//
|
||||||
|
// typedef Alloc::pointer | value_type* pointer;
|
||||||
|
// typedef Alloc::const_pointer
|
||||||
|
// | pointer_traits<pointer>::rebind<const value_type>
|
||||||
|
// const_pointer;
|
||||||
|
// typedef Alloc::void_pointer
|
||||||
|
// | pointer_traits<pointer>::rebind<void>
|
||||||
|
// void_pointer;
|
||||||
|
// typedef Alloc::const_void_pointer
|
||||||
|
// | pointer_traits<pointer>::rebind<const void>
|
||||||
|
// const_void_pointer;
|
||||||
|
|
||||||
|
template <typename Alloc>
|
||||||
|
void test_pointer()
|
||||||
|
{
|
||||||
|
typename std::allocator_traits<Alloc>::pointer vp;
|
||||||
|
typename std::allocator_traits<Alloc>::const_pointer cvp;
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Alloc>
|
||||||
|
void test_void_pointer()
|
||||||
|
{
|
||||||
|
typename std::allocator_traits<Alloc>::void_pointer vp;
|
||||||
|
typename std::allocator_traits<Alloc>::const_void_pointer cvp;
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
|
||||||
|
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
|
||||||
|
static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Foo { int x; };
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test_pointer<std::allocator<char>> ();
|
||||||
|
test_pointer<std::allocator<int>> ();
|
||||||
|
test_pointer<std::allocator<Foo>> ();
|
||||||
|
|
||||||
|
test_void_pointer<std::allocator<char>> ();
|
||||||
|
test_void_pointer<std::allocator<int>> ();
|
||||||
|
test_void_pointer<std::allocator<Foo>> ();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int main() {}
|
||||||
|
#endif
|
@ -239,7 +239,7 @@
|
|||||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2213">2213</a></td><td>Return value of std::regex_replace</td><td>Issaquah</td><td>Complete</td></tr>
|
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2213">2213</a></td><td>Return value of std::regex_replace</td><td>Issaquah</td><td>Complete</td></tr>
|
||||||
|
|
||||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2258">2258</a></td><td>a.erase(q1, q2) unable to directly return q2</td><td>Issaquah</td><td>Complete</td></tr>
|
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2258">2258</a></td><td>a.erase(q1, q2) unable to directly return q2</td><td>Issaquah</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2263">2263</a></td><td>Comparing iterators and allocator pointers with different const-character</td><td>Issaquah</td><td></td></tr>
|
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2263">2263</a></td><td>Comparing iterators and allocator pointers with different const-character</td><td>Issaquah</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2293">2293</a></td><td>Wrong facet used by num_put::do_put</td><td>Issaquah</td><td>Complete</td></tr>
|
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2293">2293</a></td><td>Wrong facet used by num_put::do_put</td><td>Issaquah</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2301">2301</a></td><td>Why is std::tie not constexpr?</td><td>Issaquah</td><td>Complete</td></tr>
|
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2301">2301</a></td><td>Why is std::tie not constexpr?</td><td>Issaquah</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2304">2304</a></td><td>Complexity of count in unordered associative containers</td><td>Issaquah</td><td>Complete</td></tr>
|
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2304">2304</a></td><td>Complexity of count in unordered associative containers</td><td>Issaquah</td><td>Complete</td></tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user