15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
931cbe0f2SLouis Dionne // UNSUPPORTED: c++03
10e5407178SEric Fiselier 
115a83710eSEric Fiselier // <functional>
125a83710eSEric Fiselier 
135a83710eSEric Fiselier // template<CopyConstructible Fn, CopyConstructible... Types>
145a83710eSEric Fiselier //   unspecified bind(Fn, Types...);
155a83710eSEric Fiselier // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
165a83710eSEric Fiselier //   unspecified bind(Fn, Types...);
175a83710eSEric Fiselier 
18*3c62198cSLouis Dionne // https://llvm.org/PR16343
195a83710eSEric Fiselier 
205a83710eSEric Fiselier #include <cmath>
215a83710eSEric Fiselier #include <functional>
225a83710eSEric Fiselier #include <cassert>
235a83710eSEric Fiselier 
247fc6a556SMarshall Clow #include "test_macros.h"
257fc6a556SMarshall Clow 
265a83710eSEric Fiselier struct power
275a83710eSEric Fiselier {
285a83710eSEric Fiselier   template <typename T>
295a83710eSEric Fiselier   T
operator ()power305a83710eSEric Fiselier   operator()(T a, T b)
315a83710eSEric Fiselier   {
32f2e24f56SStephan T. Lavavej     return static_cast<T>(std::pow(a, b));
335a83710eSEric Fiselier   }
345a83710eSEric Fiselier };
355a83710eSEric Fiselier 
365a83710eSEric Fiselier struct plus_one
375a83710eSEric Fiselier {
385a83710eSEric Fiselier   template <typename T>
395a83710eSEric Fiselier   T
operator ()plus_one405a83710eSEric Fiselier   operator()(T a)
415a83710eSEric Fiselier   {
425a83710eSEric Fiselier     return a + 1;
435a83710eSEric Fiselier   }
445a83710eSEric Fiselier };
455a83710eSEric Fiselier 
main(int,char **)462df59c50SJF Bastien int main(int, char**)
475a83710eSEric Fiselier {
485a83710eSEric Fiselier     using std::placeholders::_1;
495a83710eSEric Fiselier 
505a83710eSEric Fiselier     auto g = std::bind(power(), 2, _1);
515a83710eSEric Fiselier     assert(g(5) == 32);
525a83710eSEric Fiselier     assert(std::bind(plus_one(), g)(5) == 33);
532df59c50SJF Bastien 
542df59c50SJF Bastien   return 0;
555a83710eSEric Fiselier }
56