brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 44a566d Raw
48 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// elements_view() requires default_initializable<V> = default;12 13#include <cassert>14#include <ranges>15#include <tuple>16#include <type_traits>17 18template <bool DefaultInitializable>19struct View : std::ranges::view_base {20  int i = 42;21  constexpr explicit View()22    requires DefaultInitializable23  = default;24  std::tuple<int>* begin() const;25  std::tuple<int>* end() const;26};27 28 29// clang-format off30static_assert( std::is_default_constructible_v<std::ranges::elements_view<View<true >, 0>>);31static_assert(!std::is_default_constructible_v<std::ranges::elements_view<View<false>, 0>>);32// clang-format on33 34constexpr bool test() {35  {36    std::ranges::elements_view<View<true>, 0> ev = {};37    assert(ev.base().i == 42);38  }39 40  return true;41}42 43int main(int, char**) {44  test();45  static_assert(test());46  return 0;47}48