null.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Boost.TypeErasure library
  2. //
  3. // Copyright 2012 Steven Watanabe
  4. //
  5. // Distributed under the Boost Software License Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // $Id$
  10. #if !defined(BOOST_PP_IS_ITERATING)
  11. #ifndef BOOST_TYPE_ERASURE_DETAIL_NULL_HPP_INCLUDED
  12. #define BOOST_TYPE_ERASURE_DETAIL_NULL_HPP_INCLUDED
  13. #include <boost/config.hpp>
  14. #include <boost/throw_exception.hpp>
  15. #include <boost/type_traits/remove_pointer.hpp>
  16. #include <boost/preprocessor/iteration/iterate.hpp>
  17. #include <boost/preprocessor/repetition/enum_params.hpp>
  18. #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
  19. #include <boost/type_erasure/config.hpp>
  20. #include <boost/type_erasure/exception.hpp>
  21. namespace boost {
  22. namespace type_erasure {
  23. namespace detail {
  24. template<class Sig>
  25. struct null_throw;
  26. template<class Concept>
  27. struct get_null_vtable_entry {
  28. typedef ::boost::type_erasure::detail::null_throw<
  29. typename ::boost::remove_pointer<typename Concept::type>::type> type;
  30. };
  31. #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
  32. #define BOOST_PP_FILENAME_1 <boost/type_erasure/detail/null.hpp>
  33. #define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_ARITY)
  34. #include BOOST_PP_ITERATE()
  35. #else
  36. template<class R, class... T>
  37. struct null_throw<R(T...)> {
  38. static R value(T...) {
  39. BOOST_THROW_EXCEPTION(::boost::type_erasure::bad_function_call());
  40. }
  41. };
  42. #endif
  43. }
  44. }
  45. }
  46. #endif
  47. #else
  48. #define N BOOST_PP_ITERATION()
  49. template<class R BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)>
  50. struct null_throw<R(BOOST_PP_ENUM_PARAMS(N, T))> {
  51. static R value(BOOST_PP_ENUM_PARAMS(N, T)) {
  52. BOOST_THROW_EXCEPTION(::boost::type_erasure::bad_function_call());
  53. }
  54. };
  55. #undef N
  56. #endif