brintos

brintos / llvm-project-archived public Read only

0
0
Text · 782 B · 6dad6e3 Raw
35 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++1410// <optional>11 12// constexpr const T& optional<T>::value() const &;13 14#include <optional>15#include <type_traits>16#include <cassert>17 18using std::optional;19 20struct X21{22    constexpr int test() const {return 3;}23    int test() {return 4;}24};25 26int main(int, char**)27{28    {29        constexpr optional<X> opt;30        static_assert(opt.value().test() == 3, "");31    }32 33  return 0;34}35