1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// UNSUPPORTED: c++98, c++03 11 12// <functional> 13 14// template<CopyConstructible Fn, CopyConstructible... Types> 15// unspecified bind(Fn, Types...); 16// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> 17// unspecified bind(Fn, Types...); 18 19// https://bugs.llvm.org/show_bug.cgi?id=16343 20 21#include <cmath> 22#include <functional> 23#include <cassert> 24 25struct power 26{ 27 template <typename T> 28 T 29 operator()(T a, T b) 30 { 31 return static_cast<T>(std::pow(a, b)); 32 } 33}; 34 35struct plus_one 36{ 37 template <typename T> 38 T 39 operator()(T a) 40 { 41 return a + 1; 42 } 43}; 44 45int 46main() 47{ 48 using std::placeholders::_1; 49 50 auto g = std::bind(power(), 2, _1); 51 assert(g(5) == 32); 52 assert(std::bind(plus_one(), g)(5) == 33); 53} 54