placeholder.cpp 587 B

123456789101112131415161718192021
  1. // Copyright Louis Dionne 2013-2017
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  4. #include <boost/hana/functional/placeholder.hpp>
  5. namespace hana = boost::hana;
  6. constexpr auto plus = hana::_ + hana::_;
  7. static_assert(plus(1, 2) == 1 + 2, "");
  8. constexpr auto increment = hana::_ + 1;
  9. static_assert(increment(1) == 2, "");
  10. constexpr auto twice = 2 * hana::_;
  11. static_assert(twice(1) == 2, "");
  12. // Extra arguments are ignored.
  13. static_assert(twice(1, "ignored") == 2, "");
  14. int main() { }