boost_no_cxx11_sfinae_expr.ipp 865 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. Copyright 2017 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. // MACRO: BOOST_NO_CXX11_SFINAE_EXPR
  9. // TITLE: C++11 SFINAE for expressions
  10. // DESCRIPTION: C++11 SFINAE for expressions not supported.
  11. namespace boost_no_cxx11_sfinae_expr {
  12. template<class>
  13. struct ignore {
  14. typedef void type;
  15. };
  16. template<class T>
  17. T& object();
  18. template<class T, class E = void>
  19. struct trait {
  20. static const int value = 0;
  21. };
  22. template<class T>
  23. struct trait<T, typename ignore<decltype(&object<T>())>::type> { };
  24. template<class T>
  25. struct result {
  26. static const int value = T::value;
  27. };
  28. class type {
  29. void operator&() const { }
  30. };
  31. int test()
  32. {
  33. return result<trait<type> >::value;
  34. }
  35. } /* boost_no_cxx11_sfinae_expr */