remove_if.cpp 995 B

12345678910111213141516171819202122232425
  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/assert.hpp>
  5. #include <boost/hana/equal.hpp>
  6. #include <boost/hana/ext/std/integral_constant.hpp>
  7. #include <boost/hana/functional/compose.hpp>
  8. #include <boost/hana/optional.hpp>
  9. #include <boost/hana/remove_if.hpp>
  10. #include <boost/hana/tuple.hpp>
  11. #include <boost/hana/type.hpp>
  12. #include <type_traits>
  13. namespace hana = boost::hana;
  14. // First get the type of the object, and then call the trait on it.
  15. constexpr auto is_integral = hana::compose(hana::trait<std::is_integral>, hana::typeid_);
  16. static_assert(hana::remove_if(hana::make_tuple(1, 2.0, 3, 4.0), is_integral) == hana::make_tuple(2.0, 4.0), "");
  17. static_assert(hana::remove_if(hana::just(3.0), is_integral) == hana::just(3.0), "");
  18. BOOST_HANA_CONSTANT_CHECK(hana::remove_if(hana::just(3), is_integral) == hana::nothing);
  19. int main() { }