default.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*!
  2. @file
  3. Forward declares `boost::hana::default_` and `boost::hana::is_default`.
  4. @copyright Louis Dionne 2013-2017
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_FWD_CORE_DEFAULT_HPP
  9. #define BOOST_HANA_FWD_CORE_DEFAULT_HPP
  10. #include <boost/hana/config.hpp>
  11. BOOST_HANA_NAMESPACE_BEGIN
  12. //! @ingroup group-core
  13. //! Mark a tag-dispatched method implementation as a default implementation.
  14. //!
  15. //! When defining a new concept with tag-dispatched methods, it is
  16. //! sometimes possible to provide a default implementation for some
  17. //! method(s). Making `default_` a base class of such a default
  18. //! implementation makes it possible to detect whether the method
  19. //! was dispatched to the default implementation afterwards.
  20. //!
  21. //!
  22. //! Example
  23. //! -------
  24. //! @include example/core/default.cpp
  25. struct default_ { };
  26. //! @ingroup group-core
  27. //! Returns whether a tag-dispatched method implementation is a default
  28. //! implementation.
  29. //!
  30. //! Given a tag-dispatched method implementation `method_impl<T...>`,
  31. //! `is_default<method_impl<T...>>` returns whether `method_impl<T...>`
  32. //! is a default implementation. Note that if there is no default
  33. //! implementation for the method, then `is_default` should not be
  34. //! used unless a static assertion saying that "the method is not
  35. //! implemented" is acceptable.
  36. //!
  37. //!
  38. //! Example
  39. //! -------
  40. //! @include example/core/default.cpp
  41. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  42. template <typename Method>
  43. struct is_default { see documentation };
  44. #else
  45. template <typename T, typename = void>
  46. struct is_default;
  47. #endif
  48. BOOST_HANA_NAMESPACE_END
  49. #endif // !BOOST_HANA_FWD_CORE_DEFAULT_HPP