1a9e65961SEric Fiselier //===----------------------------------------------------------------------===// 2a9e65961SEric Fiselier // 3*57b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*57b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*57b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6a9e65961SEric Fiselier // 7a9e65961SEric Fiselier //===----------------------------------------------------------------------===// 8a9e65961SEric Fiselier 9a9e65961SEric Fiselier // UNSUPPORTED: c++98, c++03, c++11, c++14 10a9e65961SEric Fiselier // <optional> 11a9e65961SEric Fiselier 12a9e65961SEric Fiselier // constexpr explicit optional<T>::operator bool() const noexcept; 13a9e65961SEric Fiselier 14a9e65961SEric Fiselier #include <optional> 15a9e65961SEric Fiselier #include <type_traits> 16a9e65961SEric Fiselier #include <cassert> 17a9e65961SEric Fiselier 18a9e65961SEric Fiselier #include "test_macros.h" 19a9e65961SEric Fiselier 20a9e65961SEric Fiselier int main() 21a9e65961SEric Fiselier { 22a9e65961SEric Fiselier using std::optional; 23a9e65961SEric Fiselier { 24a9e65961SEric Fiselier const optional<int> opt; ((void)opt); 25a9e65961SEric Fiselier ASSERT_NOEXCEPT(bool(opt)); 26a9e65961SEric Fiselier static_assert(!std::is_convertible<optional<int>, bool>::value, ""); 27a9e65961SEric Fiselier } 28a9e65961SEric Fiselier { 29a9e65961SEric Fiselier constexpr optional<int> opt; 30a9e65961SEric Fiselier static_assert(!opt, ""); 31a9e65961SEric Fiselier } 32a9e65961SEric Fiselier { 33a9e65961SEric Fiselier constexpr optional<int> opt(0); 34a9e65961SEric Fiselier static_assert(opt, ""); 35a9e65961SEric Fiselier } 36a9e65961SEric Fiselier } 37