mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 03:32:35 +08:00
Mark LWG issue 2450 as complete.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271473 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#ifndef POINTER_COMPARISON_TEST_HELPER_HPP
|
||||
#define POINTER_COMPARISON_TEST_HELPER_HPP
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T, template<class> class CompareTemplate>
|
||||
void do_pointer_comparison_test() {
|
||||
typedef CompareTemplate<T*> Compare;
|
||||
typedef CompareTemplate<std::uintptr_t> UIntCompare;
|
||||
#if TEST_STD_VER > 11
|
||||
typedef CompareTemplate<void> VoidCompare;
|
||||
#else
|
||||
typedef Compare VoidCompare;
|
||||
#endif
|
||||
std::vector<std::shared_ptr<T> > pointers;
|
||||
const std::size_t test_size = 100;
|
||||
for (int i=0; i < test_size; ++i)
|
||||
pointers.push_back(std::shared_ptr<T>(new T()));
|
||||
Compare comp;
|
||||
UIntCompare ucomp;
|
||||
VoidCompare vcomp;
|
||||
for (int i=0; i < test_size; ++i) {
|
||||
for (int j=0; j < test_size; ++j) {
|
||||
T* lhs = pointers[i].get();
|
||||
T* rhs = pointers[j].get();
|
||||
std::uintptr_t lhs_uint = reinterpret_cast<std::uintptr_t>(lhs);
|
||||
std::uintptr_t rhs_uint = reinterpret_cast<std::uintptr_t>(rhs);
|
||||
assert(comp(lhs, rhs) == ucomp(lhs_uint, rhs_uint));
|
||||
assert(vcomp(lhs, rhs) == ucomp(lhs_uint, rhs_uint));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // POINTER_COMPARISON_TEST_HELPER_HPP
|
||||
Reference in New Issue
Block a user