issue_90.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/first.hpp>
  5. #include <boost/hana/pair.hpp>
  6. #include <boost/hana/second.hpp>
  7. #include <utility>
  8. namespace hana = boost::hana;
  9. template <typename T>
  10. T const& cref(T& t) { return t; }
  11. // a non-movable, non-copyable type
  12. struct RefOnly {
  13. RefOnly() = default;
  14. RefOnly(RefOnly const&) = delete;
  15. RefOnly(RefOnly&&) = delete;
  16. };
  17. int main() {
  18. // This test makes sure that we return the proper reference types from
  19. // `first` and `second`.
  20. hana::pair<RefOnly, RefOnly> p;
  21. {
  22. RefOnly&& r1 = hana::first(std::move(p));
  23. RefOnly& r2 = hana::first(p);
  24. RefOnly const& r3 = hana::first(cref(p));
  25. (void)r1; (void)r2; (void)r3;
  26. }
  27. {
  28. RefOnly&& r1 = hana::second(std::move(p));
  29. RefOnly& r2 = hana::second(p);
  30. RefOnly const& r3 = hana::second(cref(p));
  31. (void)r1; (void)r2; (void)r3;
  32. }
  33. }