47 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// functional12 13// template <class F, class... Args>14// constexpr unspecified bind_front(F&&, Args&&...);15 16#include <functional>17 18constexpr int pass(const int n) { return n; }19 20int simple(int n) { return n; }21 22template<class T>23T do_nothing(T t) { return t; }24 25struct NotMoveConst26{27 NotMoveConst(NotMoveConst &&) = delete;28 NotMoveConst(NotMoveConst const&) = delete;29 30 NotMoveConst(int) { }31};32 33void testNotMoveConst(NotMoveConst) { }34 35void f() {36 int n = 1;37 const int c = 1;38 39 auto p = std::bind_front(pass, c);40 static_assert(p() == 1); // expected-error {{static assertion expression is not an integral constant expression}}41 42 auto d = std::bind_front(do_nothing, n); // expected-error {{no matching function for call to 'bind_front'}}43 44 auto t = std::bind_front(testNotMoveConst, NotMoveConst(0)); // expected-error {{no matching function for call to 'bind_front'}}45 // expected-error@*:* 0-1{{call to deleted constructor of 'NotMoveConst'}}46}47