brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · eda9266 Raw
45 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// constexpr explicit elements_view(V base);12 13#include <cassert>14#include <ranges>15#include <tuple>16#include <type_traits>17#include <utility>18 19#include "MoveOnly.h"20 21struct View : std::ranges::view_base {22  MoveOnly mo;23  std::tuple<int>* begin() const;24  std::tuple<int>* end() const;25};26 27// Test Explicit28static_assert(std::is_constructible_v<std::ranges::elements_view<View, 0>, View>);29static_assert(!std::is_convertible_v<View, std::ranges::elements_view<View, 0>>);30 31constexpr bool test() {32  {33    std::ranges::elements_view<View, 0> ev{View{{}, MoveOnly{5}}};34    assert(std::move(ev).base().mo.get() == 5);35  }36 37  return true;38}39 40int main(int, char**) {41  test();42  static_assert(test());43  return 0;44}45