none.hpp 877 B

12345678910111213141516171819202122232425262728
  1. #ifndef BOOST_CONTRACT_DETAIL_NONE_HPP_
  2. #define BOOST_CONTRACT_DETAIL_NONE_HPP_
  3. // Copyright (C) 2008-2018 Lorenzo Caminiti
  4. // Distributed under the Boost Software License, Version 1.0 (see accompanying
  5. // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
  6. // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
  7. namespace boost { namespace contract { namespace detail {
  8. // Tag for "no type".
  9. struct none {
  10. // Some lib code use this to avoid unused local var warnings on #if, etc.
  11. static none& value() {
  12. static none none_value;
  13. return none_value;
  14. }
  15. };
  16. // Transform `void` to `none` type (for convenience, instead of using MPL).
  17. template<typename T> struct none_if_void { typedef T type; };
  18. template<> struct none_if_void<void> { typedef none type; };
  19. } } } // namespace
  20. #endif // #include guard