1 //===----------------------------------------------------------------------===//
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
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);
17 #include <type_traits>
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*
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
36 assert(jt
== BaseIt(a
));
41 int main(int, char**) {
43 static_assert(test());