contains.cpp 900 B

1234567891011121314151617181920212223242526272829303132
  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/contains.hpp>
  6. #include <boost/hana/integral_constant.hpp>
  7. #include <boost/hana/not.hpp>
  8. #include <boost/hana/string.hpp>
  9. namespace hana = boost::hana;
  10. struct invalid { };
  11. int main() {
  12. BOOST_HANA_CONSTANT_CHECK(hana::contains(
  13. BOOST_HANA_STRING("abcd"),
  14. hana::char_c<'a'>
  15. ));
  16. BOOST_HANA_CONSTANT_CHECK(hana::contains(
  17. BOOST_HANA_STRING("abcd"),
  18. hana::char_c<'c'>
  19. ));
  20. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains(
  21. BOOST_HANA_STRING("abcd"),
  22. hana::char_c<'e'>
  23. )));
  24. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains(
  25. BOOST_HANA_STRING("abcd"),
  26. invalid{}
  27. )));
  28. }