Skip to content

Commit 901266b

Browse files
committed
Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
1 parent 25e9321 commit 901266b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3817
-1624
lines changed

include/boost/range/as_array.hpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Boost.Range library
2+
//
3+
// Copyright Thorsten Ottosen 2006. Use, modification and
4+
// distribution is subject to the Boost Software License, Version
5+
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6+
// http://www.boost.org/LICENSE_1_0.txt)
7+
//
8+
// For more information, see http://www.boost.org/libs/range/
9+
//
10+
11+
#ifndef BOOST_RANGE_AS_ARRAY_HPP
12+
#define BOOST_RANGE_AS_ARRAY_HPP
13+
14+
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15+
# pragma once
16+
#endif
17+
18+
#include <boost/range/iterator_range.hpp>
19+
#include <boost/range/detail/str_types.hpp>
20+
21+
namespace boost
22+
{
23+
24+
template< class R >
25+
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<R>::type >
26+
as_array( R& r )
27+
{
28+
return boost::make_iterator_range( r );
29+
}
30+
31+
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
32+
33+
template< class Range >
34+
inline boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type >
35+
as_array( const Range& r )
36+
{
37+
return boost::make_iterator_range( r );
38+
}
39+
40+
#endif
41+
42+
}
43+
44+
#endif
45+

include/boost/range/as_literal.hpp

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// Boost.Range library
2+
//
3+
// Copyright Thorsten Ottosen 2006. Use, modification and
4+
// distribution is subject to the Boost Software License, Version
5+
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6+
// http://www.boost.org/LICENSE_1_0.txt)
7+
//
8+
// For more information, see http://www.boost.org/libs/range/
9+
//
10+
11+
#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP
12+
#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP
13+
14+
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15+
# pragma once
16+
#endif
17+
18+
#if BOOST_NO_FUNCTION_TEMPLATE_ORDERING
19+
#include <boost/range/detail/as_literal.hpp>
20+
#else
21+
22+
#include <boost/range/iterator_range.hpp>
23+
#include <boost/range/detail/str_types.hpp>
24+
25+
#include <boost/detail/workaround.hpp>
26+
27+
#include <cstring>
28+
#include <cwchar>
29+
30+
namespace boost
31+
{
32+
namespace range_detail
33+
{
34+
inline std::size_t length( const char* s )
35+
{
36+
return strlen( s );
37+
}
38+
39+
inline std::size_t length( const wchar_t* s )
40+
{
41+
return wcslen( s );
42+
}
43+
44+
//
45+
// Remark: the compiler cannot choose between T* and T[sz]
46+
// overloads, so we must put the T* internal to the
47+
// unconstrained version.
48+
//
49+
50+
inline bool is_char_ptr( char* )
51+
{
52+
return true;
53+
}
54+
55+
inline bool is_char_ptr( const char* )
56+
{
57+
return true;
58+
}
59+
60+
61+
inline bool is_char_ptr( wchar_t* )
62+
{
63+
return true;
64+
}
65+
66+
inline bool is_char_ptr( const wchar_t* )
67+
{
68+
return true;
69+
}
70+
71+
template< class T >
72+
inline long is_char_ptr( T /* r */ )
73+
{
74+
return 0L;
75+
}
76+
77+
template< class T >
78+
inline iterator_range<T*>
79+
make_range( T* const r, bool )
80+
{
81+
return iterator_range<T*>( r, r + length(r) );
82+
}
83+
84+
template< class T >
85+
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<T>::type>
86+
make_range( T& r, long )
87+
{
88+
return boost::make_iterator_range( r );
89+
}
90+
91+
}
92+
93+
template< class Range >
94+
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type>
95+
as_literal( Range& r )
96+
{
97+
return range_detail::make_range( r, range_detail::is_char_ptr(r) );
98+
}
99+
100+
template< class Range >
101+
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type>
102+
as_literal( const Range& r )
103+
{
104+
return range_detail::make_range( r, range_detail::is_char_ptr(r) );
105+
}
106+
107+
template< class Char, std::size_t sz >
108+
inline iterator_range<Char*> as_literal( Char (&arr)[sz] )
109+
{
110+
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590
111+
return boost::make_iterator_range<Char*>( arr, arr + sz - 1 );
112+
#else
113+
return boost::make_iterator_range( arr, arr + sz - 1 );
114+
#endif
115+
}
116+
117+
118+
template< class Char, std::size_t sz >
119+
inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] )
120+
{
121+
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590
122+
return boost::make_iterator_range<const Char*>( arr, arr + sz - 1 );
123+
#else
124+
return boost::make_iterator_range( arr, arr + sz - 1 );
125+
#endif
126+
}
127+
}
128+
129+
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
130+
131+
#endif

0 commit comments

Comments
 (0)