Louis Dionne 902e28def6 [libc++] Refactor .compile.fail.cpp tests for std::function
Some of those .compile.fail.cpp tests had become incorrect and they
were not testing anything. In general, .compile.fail.cpp tests are
bad because they make it way too easy to write garbage tests. Indeed,
the test could fail to compile due to any reason whatsoever (even a
typo) and it would appear to work correctly.

Differential Revision: https://reviews.llvm.org/D138731
2022-12-14 10:55:46 -05:00

25 lines
839 B
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14
// <functional>
//
// Make sure we can't initialize a std::function using an allocator (http://wg21.link/p0302r1).
// These constructors were removed in C++17.
#include <functional>
#include <memory>
struct S : public std::function<void()> { using function::function; };
void f() {
S f1( [](){} );
S f2(std::allocator_arg, std::allocator<int>{}, f1); // expected-error {{no matching constructor for initialization of 'S'}}
}