implicit.cpp 859 B

1234567891011121314151617181920212223242526272829
  1. /*=============================================================================
  2. Copyright (c) 2017 Paul Fultz II
  3. implicit.cpp
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #include <boost/hof/implicit.hpp>
  8. template<class T>
  9. struct auto_caster
  10. {
  11. template<class U>
  12. T operator()(U x)
  13. {
  14. return T(x);
  15. }
  16. };
  17. int main()
  18. {
  19. boost::hof::implicit<auto_caster> auto_cast = {};
  20. auto x = auto_cast(1.5);
  21. (void)x;
  22. // This is not possible in c++17 due to guaranteed copy elison
  23. #if BOOST_HOF_HAS_STD_17 || (defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7)
  24. static_assert(false, "Always fail");
  25. #endif
  26. }