c_str.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright Andrey Semashev 2016.
  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 c_str.hpp
  9. * \author Andrey Semashev
  10. * \date 23.02.2016
  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_C_STR_HPP_INCLUDED_
  16. #define BOOST_LOG_DETAIL_C_STR_HPP_INCLUDED_
  17. #include <string>
  18. #include <boost/core/enable_if.hpp>
  19. #include <boost/log/detail/config.hpp>
  20. #include <boost/log/detail/is_character_type.hpp>
  21. #include <boost/log/detail/header.hpp>
  22. #ifdef BOOST_HAS_PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. namespace boost {
  26. BOOST_LOG_OPEN_NAMESPACE
  27. namespace aux {
  28. template< typename T >
  29. inline typename boost::enable_if_c< is_character_type< T >::value, const T* >::type c_str(const T* str) BOOST_NOEXCEPT
  30. {
  31. return str;
  32. }
  33. template< typename T, typename TraitsT, typename AllocatorT >
  34. inline typename boost::enable_if_c< is_character_type< T >::value, const T* >::type c_str(std::basic_string< T, TraitsT, AllocatorT > const& str) BOOST_NOEXCEPT
  35. {
  36. return str.c_str();
  37. }
  38. } // namespace aux
  39. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  40. } // namespace boost
  41. #include <boost/log/detail/footer.hpp>
  42. #endif // BOOST_LOG_DETAIL_C_STR_HPP_INCLUDED_