deduce_char_type.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 deduce_char_type.hpp
  9. * \author Andrey Semashev
  10. * \date 17.11.2012
  11. *
  12. * \brief 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_DEDUCE_CHAR_TYPE_HPP_INCLUDED_
  16. #define BOOST_LOG_DETAIL_DEDUCE_CHAR_TYPE_HPP_INCLUDED_
  17. #include <boost/log/detail/config.hpp>
  18. #include <boost/log/detail/header.hpp>
  19. #ifdef BOOST_HAS_PRAGMA_ONCE
  20. #pragma once
  21. #endif
  22. namespace boost {
  23. BOOST_LOG_OPEN_NAMESPACE
  24. namespace aux {
  25. template< typename T >
  26. struct deduced_char_type;
  27. template< >
  28. struct deduced_char_type< char >
  29. {
  30. typedef char type;
  31. };
  32. template< >
  33. struct deduced_char_type< const char >
  34. {
  35. typedef char type;
  36. };
  37. template< >
  38. struct deduced_char_type< wchar_t >
  39. {
  40. typedef wchar_t type;
  41. };
  42. template< >
  43. struct deduced_char_type< const wchar_t >
  44. {
  45. typedef wchar_t type;
  46. };
  47. //! Auxiliary traits to detect character type from a string
  48. template< typename RangeT >
  49. struct deduce_char_type :
  50. public deduced_char_type< typename RangeT::value_type >
  51. {
  52. };
  53. template< typename T >
  54. struct deduce_char_type< T* > :
  55. public deduced_char_type< T >
  56. {
  57. };
  58. template< typename T >
  59. struct deduce_char_type< T* const > :
  60. public deduced_char_type< T >
  61. {
  62. };
  63. template< typename T, unsigned int CountV >
  64. struct deduce_char_type< T[CountV] > :
  65. public deduced_char_type< T >
  66. {
  67. };
  68. template< typename T >
  69. struct deduce_char_type< T& > :
  70. public deduce_char_type< T >
  71. {
  72. };
  73. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  74. template< typename T >
  75. struct deduce_char_type< T&& > :
  76. public deduce_char_type< T >
  77. {
  78. };
  79. #endif
  80. } // namespace aux
  81. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  82. } // namespace boost
  83. #include <boost/log/detail/footer.hpp>
  84. #endif // BOOST_LOG_DETAIL_DEDUCE_CHAR_TYPE_HPP_INCLUDED_