native_typeof.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file native_typeof.hpp
  9. * \author Andrey Semashev
  10. * \date 08.03.2009
  11. *
  12. * This header is the Boost.Log library implementation, see the library documentation
  13. * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
  14. */
  15. #ifndef BOOST_LOG_DETAIL_NATIVE_TYPEOF_HPP_INCLUDED_
  16. #define BOOST_LOG_DETAIL_NATIVE_TYPEOF_HPP_INCLUDED_
  17. #include <boost/log/detail/config.hpp>
  18. #ifdef BOOST_HAS_PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. #if !defined(BOOST_NO_CXX11_DECLTYPE)
  22. namespace boost {
  23. BOOST_LOG_OPEN_NAMESPACE
  24. namespace aux {
  25. template< typename T >
  26. T get_root_type(T const&);
  27. } // namespace aux
  28. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  29. } // namespace boost
  30. #define BOOST_LOG_TYPEOF(x) decltype(::boost::log::aux::get_root_type(x))
  31. #elif defined(__COMO__) && defined(__GNUG__)
  32. #define BOOST_LOG_TYPEOF(x) typeof(x)
  33. #elif defined(__GNUC__) || defined(__MWERKS__)
  34. #define BOOST_LOG_TYPEOF(x) __typeof__(x)
  35. #endif
  36. #if !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
  37. #define BOOST_LOG_AUTO(var, expr) auto var = (expr)
  38. #endif
  39. #if !defined(BOOST_LOG_AUTO) && defined(BOOST_LOG_TYPEOF)
  40. #define BOOST_LOG_AUTO(var, expr) BOOST_LOG_TYPEOF((expr)) var = (expr)
  41. #endif
  42. #endif // BOOST_LOG_DETAIL_NATIVE_TYPEOF_HPP_INCLUDED_