Blame view

3rdparty/boost_1_81_0/boost/lexical_cast.hpp 3.2 KB
63e88f80   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  // Copyright Kevlin Henney, 2000-2005.
  // Copyright Alexander Nasonov, 2006-2010.
  // Copyright Antony Polukhin, 2011-2022.
  //
  // Distributed under the Boost Software License, Version 1.0. (See
  // accompanying file LICENSE_1_0.txt or copy at
  // http://www.boost.org/LICENSE_1_0.txt)
  //
  // what:  lexical_cast custom keyword cast
  // who:   contributed by Kevlin Henney,
  //        enhanced with contributions from Terje Slettebo,
  //        with additional fixes and suggestions from Gennaro Prota,
  //        Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov,
  //        Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann,
  //        Cheng Yang, Matthew Bradbury, David W. Birdsall, Pavel Korzh and other Boosters
  // when:  November 2000, March 2003, June 2005, June 2006, March 2011 - 2014
  
  #ifndef BOOST_LEXICAL_CAST_INCLUDED
  #define BOOST_LEXICAL_CAST_INCLUDED
  
  #include <boost/config.hpp>
  #ifdef BOOST_HAS_PRAGMA_ONCE
  #   pragma once
  #endif
  
  #if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
  #define BOOST_LCAST_NO_WCHAR_T
  #endif
  
  #include <boost/range/iterator_range_core.hpp>
  #include <boost/lexical_cast/bad_lexical_cast.hpp>
  #include <boost/lexical_cast/try_lexical_convert.hpp>
  
  namespace boost
  {
      template <typename Target, typename Source>
      inline Target lexical_cast(const Source &arg)
      {
          Target result = Target();
  
          if (!boost::conversion::detail::try_lexical_convert(arg, result)) {
              boost::conversion::detail::throw_bad_cast<Source, Target>();
          }
  
          return result;
      }
  
      template <typename Target>
      inline Target lexical_cast(const char* chars, std::size_t count)
      {
          return ::boost::lexical_cast<Target>(
              ::boost::iterator_range<const char*>(chars, chars + count)
          );
      }
  
      template <typename Target>
      inline Target lexical_cast(const unsigned char* chars, std::size_t count)
      {
          return ::boost::lexical_cast<Target>(
              ::boost::iterator_range<const unsigned char*>(chars, chars + count)
          );
      }
  
      template <typename Target>
      inline Target lexical_cast(const signed char* chars, std::size_t count)
      {
          return ::boost::lexical_cast<Target>(
              ::boost::iterator_range<const signed char*>(chars, chars + count)
          );
      }
  
  #ifndef BOOST_LCAST_NO_WCHAR_T
      template <typename Target>
      inline Target lexical_cast(const wchar_t* chars, std::size_t count)
      {
          return ::boost::lexical_cast<Target>(
              ::boost::iterator_range<const wchar_t*>(chars, chars + count)
          );
      }
  #endif
  #ifndef BOOST_NO_CXX11_CHAR16_T
      template <typename Target>
      inline Target lexical_cast(const char16_t* chars, std::size_t count)
      {
          return ::boost::lexical_cast<Target>(
              ::boost::iterator_range<const char16_t*>(chars, chars + count)
          );
      }
  #endif
  #ifndef BOOST_NO_CXX11_CHAR32_T
      template <typename Target>
      inline Target lexical_cast(const char32_t* chars, std::size_t count)
      {
          return ::boost::lexical_cast<Target>(
              ::boost::iterator_range<const char32_t*>(chars, chars + count)
          );
      }
  #endif
  
  } // namespace boost
  
  #undef BOOST_LCAST_NO_WCHAR_T
  
  #endif // BOOST_LEXICAL_CAST_INCLUDED