brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 0fe7222 Raw
56 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++0310 11// <functional>12 13// template<CopyConstructible Fn, CopyConstructible... Types>14//   unspecified bind(Fn, Types...);    // constexpr since C++2015// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>16//   unspecified bind(Fn, Types...);    // constexpr since C++2017 18// https://llvm.org/PR1634319 20#include <functional>21#include <cassert>22 23#include "test_macros.h"24 25struct multiply {26  template <typename T>27  TEST_CONSTEXPR_CXX20 T operator()(T a, T b) {28    return a * b;29  }30};31 32struct plus_one {33  template <typename T>34  TEST_CONSTEXPR_CXX20 T operator()(T a) {35    return a + 1;36  }37};38 39TEST_CONSTEXPR_CXX20 bool test() {40  using std::placeholders::_1;41  auto g = std::bind(multiply(), 2, _1);42  assert(g(5) == 10);43  assert(std::bind(plus_one(), g)(5) == 11);44 45  return true;46}47 48int main(int, char**) {49  test();50#if TEST_STD_VER >= 2051  static_assert(test());52#endif53 54  return 0;55}56