Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / iterators / predef.iterators / iterators.common / ctor.converting.pass.cpp
blob741654ea640ca5c6b37ac6e58fd7941aa6fda6e2
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // template<class I2, class S2>
12 // requires convertible_to<const I2&, I> && convertible_to<const S2&, S>
13 // constexpr common_iterator(const common_iterator<I2, S2>& x);
15 #include <cassert>
16 #include <iterator>
17 #include <type_traits>
19 constexpr bool test()
21 struct Base {};
22 struct Derived : Base {};
24 using BaseIt = std::common_iterator<Base*, const Base*>;
25 using DerivedIt = std::common_iterator<Derived*, const Derived*>;
26 static_assert(std::is_convertible_v<DerivedIt, BaseIt>); // Derived* to Base*
27 static_assert(!std::is_constructible_v<DerivedIt, BaseIt>); // Base* to Derived*
29 Derived a[10] = {};
30 DerivedIt it = DerivedIt(a); // the iterator type
31 BaseIt jt = BaseIt(it);
32 assert(jt == BaseIt(a));
34 it = DerivedIt((const Derived*)a); // the sentinel type
35 jt = BaseIt(it);
36 assert(jt == BaseIt(a));
38 return true;
41 int main(int, char**) {
42 test();
43 static_assert(test());
45 return 0;