// { dg-do compile { target c++17 } }
// Copyright (C) 2020-2023 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// .
#include
int i;
struct Cont
{
Cont() noexcept;
Cont(Cont&&) noexcept;
Cont(const Cont&);
Cont(int);
Cont(std::initializer_list, int) noexcept;
Cont(std::initializer_list, const char*);
};
const Cont c{};
template
struct can_make_optional1
: std::false_type
{ };
template
struct can_make_optional1()))>>
: std::true_type
{ };
static_assert( can_make_optional1::value );
static_assert( noexcept(std::make_optional(1)) );
static_assert( can_make_optional1::value );
static_assert( noexcept(std::make_optional(i)) );
static_assert( ! can_make_optional1::value );
static_assert( can_make_optional1::value );
static_assert( noexcept(std::make_optional(Cont{})) );
static_assert( can_make_optional1::value );
static_assert( ! noexcept(std::make_optional(c)) );
template
struct can_make_optional2
: std::false_type
{ };
template
struct can_make_optional2(std::declval()))>>
: std::true_type
{ };
static_assert( can_make_optional2::value );
static_assert( noexcept(std::make_optional(1)) );
static_assert( can_make_optional2::value );
static_assert( noexcept(std::make_optional(i)) );
static_assert( ! can_make_optional2::value );
static_assert( can_make_optional2::value );
static_assert( noexcept(std::make_optional({})) );
static_assert( can_make_optional2::value );
static_assert( ! noexcept(std::make_optional(c)) );
static_assert( can_make_optional2::value );
static_assert( ! noexcept(std::make_optional(1)) );
template
struct can_make_optional3
: std::false_type
{ };
template
struct can_make_optional3({1,2}, std::declval()))>>
: std::true_type
{ };
static_assert( can_make_optional3::value );
static_assert( noexcept(std::make_optional({1,2}, 1)) );
static_assert( can_make_optional3::value );
static_assert( ! noexcept(std::make_optional({1,2}, "")) );
static_assert( !can_make_optional3::value );