libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

mem_fun1_t.pass.cpp (869B)


      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 // <functional>
     11 // REQUIRES: c++98 || c++03 || c++11 || c++14
     12 
     13 // mem_fun1_t
     14 
     15 #include <functional>
     16 #include <type_traits>
     17 #include <cassert>
     18 
     19 struct A
     20 {
     21     char a1() {return 5;}
     22     short a2(int i) {return short(i+1);}
     23     int a3() const {return 1;}
     24     double a4(unsigned i) const {return i-1;}
     25 };
     26 
     27 int main()
     28 {
     29     typedef std::mem_fun1_t<short, A, int> F;
     30     static_assert((std::is_base_of<std::binary_function<A*, int, short>, F>::value), "");
     31     const F f(&A::a2);
     32     A a;
     33     assert(f(&a, 5) == 6);
     34 }