Home | History | Annotate | Download | only in tuple.apply
      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, c++11
     11 
     12 // <experimental/tuple>
     13 
     14 // template <class F, class T> constexpr decltype(auto) apply(F &&, T &&)
     15 
     16 // Testing ref qualified functions
     17 
     18 #include <experimental/tuple>
     19 #include <cassert>
     20 
     21 struct func_obj
     22 {
     23     constexpr func_obj() {}
     24 
     25     constexpr int operator()() const & { return 1; }
     26     constexpr int operator()() const && { return 2; }
     27     constexpr int operator()() & { return 3; }
     28     constexpr int operator()() && { return 4; }
     29 };
     30 
     31 namespace ex = std::experimental;
     32 
     33 int main()
     34 {
     35 // TODO(ericwf): Re-enable constexpr support
     36 /*
     37     {
     38         constexpr func_obj f;
     39         constexpr std::tuple<> tp;
     40 
     41         static_assert(1 == ex::apply(static_cast<func_obj const &>(f), tp), "");
     42         static_assert(2 == ex::apply(static_cast<func_obj const &&>(f), tp), "");
     43     }
     44 */
     45     {
     46         func_obj f;
     47         std::tuple<> tp;
     48         assert(1 == ex::apply(static_cast<func_obj const &>(f), tp));
     49         assert(2 == ex::apply(static_cast<func_obj const &&>(f), tp));
     50         assert(3 == ex::apply(static_cast<func_obj &>(f), tp));
     51         assert(4 == ex::apply(static_cast<func_obj &&>(f), tp));
     52     }
     53 }
     54