brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 0e0437b 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++03, c++1110 11// <functional>12 13// template<class T> struct is_placeholder;14//   A program may specialize this template for a program-defined type T15//   to have a base characteristic of integral_constant<int, N> with N > 016//   to indicate that T should be treated as a placeholder type.17//   https://llvm.org/PR5175318 19#include <cassert>20#include <functional>21#include <type_traits>22#include <utility>23 24struct My2 {};25template<> struct std::is_placeholder<My2> : std::integral_constant<int, 2> {};26 27int main(int, char**)28{29  {30    auto f = [](auto x) { return 10*x + 9; };31    My2 place;32    auto bound = std::bind(f, place);33    assert(bound(7, 8) == 89);34  }35  {36    auto f = [](auto x) { return 10*x + 9; };37    const My2 place;38    auto bound = std::bind(f, place);39    assert(bound(7, 8) == 89);40  }41  {42    auto f = [](auto x) { return 10*x + 9; };43    My2 place;44    auto bound = std::bind(f, std::move(place));45    assert(bound(7, 8) == 89);46  }47  {48    auto f = [](auto x) { return 10*x + 9; };49    const My2 place;50    auto bound = std::bind(f, std::move(place));51    assert(bound(7, 8) == 89);52  }53 54  return 0;55}56