forked from boostorg/tuple
Compare commits
23 Commits
svn-branch
...
boost-1.30
Author | SHA1 | Date | |
---|---|---|---|
822e06e06b | |||
98d2bc4220 | |||
9d262adad7 | |||
1972959fda | |||
496cc84960 | |||
c1a28e5d81 | |||
4d4fe0010f | |||
8992af95d1 | |||
ae40fce7c9 | |||
607b65a946 | |||
2c213c8295 | |||
5b8506c39b | |||
22f56bbe58 | |||
fb8fa3c7b6 | |||
cc5a2ae388 | |||
4cd544f4c1 | |||
74a2ab1242 | |||
7896766f8f | |||
0a33edd21d | |||
53c1bb2c20 | |||
ea8d71487d | |||
6a92d10f25 | |||
3570bdb6b6 |
@ -20,7 +20,9 @@ Suppose <code>T</code> is a tuple type, and <code>N</code> is a constant integra
|
||||
|
||||
<code><pre>element<N, T>::type</pre></code>
|
||||
|
||||
gives the type of the <code>N</code>th element in the tuple type <code>T</code>.
|
||||
gives the type of the <code>N</code>th element in the tuple type <code>T</code>. If <code>T</code> is const, the resulting type is const qualified as well.
|
||||
Note that the constness of <code>T</code> does not affect reference type
|
||||
elements.
|
||||
</p>
|
||||
|
||||
<code><pre>length<T>::value</pre></code>
|
||||
|
@ -97,7 +97,7 @@ tuple<A*, tuple<const A*, const B&, C>, bool, void*>
|
||||
|
||||
<p>
|
||||
The tuple constructor takes the tuple elements as arguments.
|
||||
For an <i>n</i>-element tuple, the constructor can be invoked with <i>k</i> arguments, where 0 < <i>k</i> <= <i>n</i>.
|
||||
For an <i>n</i>-element tuple, the constructor can be invoked with <i>k</i> arguments, where 0 <= <i>k</i> <= <i>n</i>.
|
||||
For example:
|
||||
<pre><code>tuple<int, double>()
|
||||
tuple<int, double>(1)
|
||||
@ -264,10 +264,10 @@ A tuple can be copy constructed from another tuple, provided that the element ty
|
||||
Analogously, a tuple can be assigned to another tuple, provided that the element types are element-wise assignable.
|
||||
For example:
|
||||
|
||||
<pre><code>class A;
|
||||
<pre><code>class A {};
|
||||
class B : public A {};
|
||||
struct C { C(); C(const B&); }
|
||||
struct D { operator C() const; }
|
||||
struct C { C(); C(const B&); };
|
||||
struct D { operator C() const; };
|
||||
tuple<char, B*, B, D> t;
|
||||
...
|
||||
tuple<int, A*, C, C> a(t); // ok
|
||||
|
@ -19,7 +19,7 @@
|
||||
// ( and other bugs ) per suggestion of Jens Maurer
|
||||
// simplified element type accessors + bug fix (Jeremy Siek)
|
||||
// Several changes/additions according to suggestions by Doug Gregor,
|
||||
// William Kempf, Vesa Karvonen, John Max Skaller, Ed Brey, Beman Davis,
|
||||
// William Kempf, Vesa Karvonen, John Max Skaller, Ed Brey, Beman Dawes,
|
||||
// David Abrahams.
|
||||
|
||||
// Revision history:
|
||||
@ -108,12 +108,12 @@ struct get_class {
|
||||
template<class RET, class HT, class TT >
|
||||
inline static RET get(const cons<HT, TT>& t)
|
||||
{
|
||||
return get_class<N-1>::template get<RET>(t.tail);
|
||||
return get_class<N-1>::BOOST_NESTED_TEMPLATE get<RET>(t.tail);
|
||||
}
|
||||
template<class RET, class HT, class TT >
|
||||
inline static RET get(cons<HT, TT>& t)
|
||||
{
|
||||
return get_class<N-1>::template get<RET>(t.tail);
|
||||
return get_class<N-1>::BOOST_NESTED_TEMPLATE get<RET>(t.tail);
|
||||
}
|
||||
};
|
||||
|
||||
@ -153,6 +153,21 @@ struct element<0,T>
|
||||
typedef typename T::head_type type;
|
||||
};
|
||||
|
||||
template<int N, class T>
|
||||
struct element<N, const T>
|
||||
{
|
||||
private:
|
||||
typedef typename T::tail_type Next;
|
||||
typedef typename element<N-1, Next>::type unqualified_type;
|
||||
public:
|
||||
typedef typename boost::add_const<unqualified_type>::type type;
|
||||
};
|
||||
template<class T>
|
||||
struct element<0,const T>
|
||||
{
|
||||
typedef typename boost::add_const<typename T::head_type>::type type;
|
||||
};
|
||||
|
||||
// -get function templates -----------------------------------------------
|
||||
// Usage: get<N>(aTuple)
|
||||
|
||||
@ -190,7 +205,7 @@ inline typename access_traits<
|
||||
typename element<N, cons<HT, TT> >::type
|
||||
>::non_const_type
|
||||
get(cons<HT, TT>& c BOOST_TUPLE_DUMMY_PARM) {
|
||||
return detail::get_class<N>::template
|
||||
return detail::get_class<N>::BOOST_NESTED_TEMPLATE
|
||||
get<
|
||||
typename access_traits<
|
||||
typename element<N, cons<HT, TT> >::type
|
||||
@ -205,7 +220,7 @@ inline typename access_traits<
|
||||
typename element<N, cons<HT, TT> >::type
|
||||
>::const_type
|
||||
get(const cons<HT, TT>& c BOOST_TUPLE_DUMMY_PARM) {
|
||||
return detail::get_class<N>::template
|
||||
return detail::get_class<N>::BOOST_NESTED_TEMPLATE
|
||||
get<
|
||||
typename access_traits<
|
||||
typename element<N, cons<HT, TT> >::type
|
||||
@ -332,6 +347,7 @@ struct cons<HT, null_type> {
|
||||
|
||||
typedef HT head_type;
|
||||
typedef null_type tail_type;
|
||||
typedef cons<HT, null_type> self_type;
|
||||
|
||||
typedef typename
|
||||
detail::wrap_non_storeable_type<head_type>::type stored_head_type;
|
||||
@ -360,7 +376,7 @@ struct cons<HT, null_type> {
|
||||
const null_type&, const null_type&, const null_type&)
|
||||
: head (t1) {}
|
||||
|
||||
cons(const null_type& t1,
|
||||
cons(const null_type&,
|
||||
const null_type&, const null_type&, const null_type&,
|
||||
const null_type&, const null_type&, const null_type&,
|
||||
const null_type&, const null_type&, const null_type&)
|
||||
@ -379,7 +395,7 @@ struct cons<HT, null_type> {
|
||||
|
||||
template <int N>
|
||||
typename access_traits<
|
||||
typename element<N, cons>::type
|
||||
typename element<N, self_type>::type
|
||||
>::non_const_type
|
||||
get(BOOST_TUPLE_SINGLE_DUMMY_PARM) {
|
||||
return boost::tuples::get<N>(*this);
|
||||
@ -387,7 +403,7 @@ struct cons<HT, null_type> {
|
||||
|
||||
template <int N>
|
||||
typename access_traits<
|
||||
typename element<N, cons>::type
|
||||
typename element<N, self_type>::type
|
||||
>::const_type
|
||||
get(BOOST_TUPLE_SINGLE_DUMMY_PARM) const {
|
||||
return boost::tuples::get<N>(*this);
|
||||
|
@ -98,6 +98,7 @@ namespace tuples {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct add_const_reference : add_reference<typename add_const<T>::type> {};
|
||||
} // end of namespace detail
|
||||
|
||||
// cons builds a heterogenous list of types
|
||||
@ -108,36 +109,42 @@ namespace tuples {
|
||||
typedef Head head_type;
|
||||
typedef Tail tail_type;
|
||||
|
||||
private:
|
||||
typedef typename boost::add_reference<head_type>::type head_ref;
|
||||
typedef typename boost::add_reference<tail_type>::type tail_ref;
|
||||
typedef typename detail::add_const_reference<head_type>::type head_cref;
|
||||
typedef typename detail::add_const_reference<tail_type>::type tail_cref;
|
||||
public:
|
||||
head_type head;
|
||||
tail_type tail;
|
||||
|
||||
typename boost::add_reference<head_type>::type get_head() { return head; }
|
||||
typename boost::add_reference<tail_type>::type get_tail() { return tail; }
|
||||
head_ref get_head() { return head; }
|
||||
tail_ref get_tail() { return tail; }
|
||||
|
||||
typename boost::add_reference<const head_type>::type get_head() const { return head; }
|
||||
typename boost::add_reference<const tail_type>::type get_tail() const { return tail; }
|
||||
head_cref get_head() const { return head; }
|
||||
tail_cref get_tail() const { return tail; }
|
||||
|
||||
#if defined BOOST_MSVC
|
||||
template<typename Tail>
|
||||
explicit cons(const head_type& h /* = head_type() */, // causes MSVC 6.5 to barf.
|
||||
explicit cons(head_cref h /* = head_type() */, // causes MSVC 6.5 to barf.
|
||||
const Tail& t) : head(h), tail(t.head, t.tail)
|
||||
{
|
||||
}
|
||||
|
||||
explicit cons(const head_type& h /* = head_type() */, // causes MSVC 6.5 to barf.
|
||||
explicit cons(head_cref h /* = head_type() */, // causes MSVC 6.5 to barf.
|
||||
const null_type& t) : head(h), tail(t)
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
template<typename T>
|
||||
explicit cons(const head_type& h, const T& t) :
|
||||
explicit cons(head_cref h, const T& t) :
|
||||
head(h), tail(t.head, t.tail)
|
||||
{
|
||||
}
|
||||
|
||||
explicit cons(const head_type& h = head_type(),
|
||||
const tail_type& t = tail_type()) :
|
||||
explicit cons(head_cref h = head_type(),
|
||||
tail_cref t = tail_type()) :
|
||||
head(h), tail(t)
|
||||
{
|
||||
}
|
||||
@ -416,20 +423,31 @@ namespace tuples {
|
||||
typedef typename mapped_tuple::cons2 cons2;
|
||||
typedef typename mapped_tuple::cons1 cons1;
|
||||
|
||||
typedef typename detail::add_const_reference<T1>::type t1_cref;
|
||||
typedef typename detail::add_const_reference<T2>::type t2_cref;
|
||||
typedef typename detail::add_const_reference<T3>::type t3_cref;
|
||||
typedef typename detail::add_const_reference<T4>::type t4_cref;
|
||||
typedef typename detail::add_const_reference<T5>::type t5_cref;
|
||||
typedef typename detail::add_const_reference<T6>::type t6_cref;
|
||||
typedef typename detail::add_const_reference<T7>::type t7_cref;
|
||||
typedef typename detail::add_const_reference<T8>::type t8_cref;
|
||||
typedef typename detail::add_const_reference<T9>::type t9_cref;
|
||||
typedef typename detail::add_const_reference<T10>::type t10_cref;
|
||||
public:
|
||||
typedef cons1 inherited;
|
||||
typedef tuple self_type;
|
||||
|
||||
explicit tuple(const T1& t1 = T1(),
|
||||
const T2& t2 = T2(),
|
||||
const T3& t3 = T3(),
|
||||
const T4& t4 = T4(),
|
||||
const T5& t5 = T5(),
|
||||
const T6& t6 = T6(),
|
||||
const T7& t7 = T7(),
|
||||
const T8& t8 = T8(),
|
||||
const T9& t9 = T9(),
|
||||
const T10& t10 = T10()) :
|
||||
explicit tuple(t1_cref t1 = T1(),
|
||||
t2_cref t2 = T2(),
|
||||
t3_cref t3 = T3(),
|
||||
t4_cref t4 = T4(),
|
||||
t5_cref t5 = T5(),
|
||||
t6_cref t6 = T6(),
|
||||
t7_cref t7 = T7(),
|
||||
t8_cref t8 = T8(),
|
||||
t9_cref t9 = T9(),
|
||||
t10_cref t10 = T10()
|
||||
) :
|
||||
cons1(t1, cons2(t2, cons3(t3, cons4(t4, cons5(t5, cons6(t6,cons7(t7,cons8(t8,cons9(t9,cons10(t10))))))))))
|
||||
{
|
||||
}
|
||||
@ -748,6 +766,9 @@ namespace tuples {
|
||||
}
|
||||
// "ignore" allows tuple positions to be ignored when using "tie".
|
||||
namespace {
|
||||
#if (defined(BOOST_MSVC) && BOOST_MSVC <= 1300) || (defined(__DECCXX_VER) && __DECCXX_VER <= 60590031)
|
||||
static
|
||||
#endif
|
||||
detail::swallow_assign ignore;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,13 @@
|
||||
#ifndef BOOST_TUPLE_HPP
|
||||
#define BOOST_TUPLE_HPP
|
||||
|
||||
#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730
|
||||
// Work around a compiler bug.
|
||||
// boost::python::tuple has to be seen by the compiler before the
|
||||
// boost::tuple class template.
|
||||
namespace boost { namespace python { class tuple; }}
|
||||
#endif
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/static_assert.hpp"
|
||||
|
||||
|
@ -36,6 +36,23 @@
|
||||
|
||||
#include "boost/tuple/tuple.hpp"
|
||||
|
||||
// This is ugly: one should be using twoargument isspace since whitspace can
|
||||
// be locale dependent, in theory at least.
|
||||
// not all libraries implement have the two-arg version, so we need to
|
||||
// use the one-arg one, which one should get with <cctype> but there seem
|
||||
// to be exceptions to this.
|
||||
|
||||
#if !defined (BOOST_NO_STD_LOCALE)
|
||||
|
||||
#include <locale> // for two-arg isspace
|
||||
|
||||
#else
|
||||
|
||||
#include <cctype> // for one-arg (old) isspace
|
||||
#include <ctype.h> // Metrowerks does not find one-arg isspace from cctype
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace tuples {
|
||||
|
||||
@ -69,9 +86,9 @@ public:
|
||||
// parentheses and space are the default manipulators
|
||||
if (!c) {
|
||||
switch(m) {
|
||||
case open : c = '('; break;
|
||||
case close : c = ')'; break;
|
||||
case delimiter : c = ' '; break;
|
||||
case detail::format_info::open : c = '('; break;
|
||||
case detail::format_info::close : c = ')'; break;
|
||||
case detail::format_info::delimiter : c = ' '; break;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
@ -92,9 +109,9 @@ public:
|
||||
// parentheses and space are the default manipulators
|
||||
if (!c) {
|
||||
switch(m) {
|
||||
case open : c = i.widen('('); break;
|
||||
case close : c = i.widen(')'); break;
|
||||
case delimiter : c = i.widen(' '); break;
|
||||
case detail::format_info::open : c = i.widen('('); break;
|
||||
case detail::format_info::close : c = i.widen(')'); break;
|
||||
case detail::format_info::delimiter : c = i.widen(' '); break;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
@ -328,7 +345,11 @@ extract_and_check_delimiter(
|
||||
{
|
||||
const char d = format_info::get_manipulator(is, del);
|
||||
|
||||
const bool is_delimiter = (!isspace(d) );
|
||||
#if defined (BOOST_NO_STD_LOCALE)
|
||||
const bool is_delimiter = !isspace(d);
|
||||
#else
|
||||
const bool is_delimiter = (!std::isspace(d, is.getloc()) );
|
||||
#endif
|
||||
|
||||
char c;
|
||||
if (is_delimiter) {
|
||||
@ -415,7 +436,14 @@ extract_and_check_delimiter(
|
||||
{
|
||||
const CharType d = format_info::get_manipulator(is, del);
|
||||
|
||||
const bool is_delimiter = (!isspace(d) );
|
||||
#if defined (BOOST_NO_STD_LOCALE)
|
||||
const bool is_delimiter = !isspace(d);
|
||||
#elif defined ( __BORLANDC__ )
|
||||
const bool is_delimiter = !std::use_facet< std::ctype< CharType > >
|
||||
(is.getloc() ).is( std::ctype_base::space, d);
|
||||
#else
|
||||
const bool is_delimiter = (!std::isspace(d, is.getloc()) );
|
||||
#endif
|
||||
|
||||
CharType c;
|
||||
if (is_delimiter) {
|
||||
|
8
index.html
Normal file
8
index.html
Normal file
@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=doc/tuple_users_guide.html">
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to <a href="doc/tuple_users_guide.html">doc/tuple_users_guide.html</a>
|
||||
</body>
|
||||
</html>
|
20
test/Jamfile
Normal file
20
test/Jamfile
Normal file
@ -0,0 +1,20 @@
|
||||
subproject libs/tuple/test ;
|
||||
|
||||
unit-test tuple_test_bench
|
||||
: tuple_test_bench.cpp
|
||||
<lib>../../test/build/test_exec_monitor
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
unit-test io_test
|
||||
: io_test.cpp
|
||||
<lib>../../test/build/test_exec_monitor
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
unit-test another_tuple_test_bench
|
||||
: another_tuple_test_bench.cpp
|
||||
<lib>../../test/build/test_exec_monitor
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
;
|
||||
|
@ -1,3 +1,17 @@
|
||||
// Copyright (C) 1999, 2000 Jaakko J<>rvi (jaakko.jarvi@cs.utu.fi)
|
||||
//
|
||||
// Permission to copy, use, sell and distribute this software is granted
|
||||
// provided this copyright notice appears in all copies.
|
||||
// Permission to modify the code and to distribute modified code is granted
|
||||
// provided this copyright notice appears in all copies, and a notice
|
||||
// that the code was modified is included with the copyright notice.
|
||||
//
|
||||
// This software is provided "as is" without express or implied warranty,
|
||||
// and with no claim as to its suitability for any purpose.
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
|
||||
// another_test_bench.cpp --------------------------------
|
||||
|
||||
// This file has various tests to see that things that shouldn't
|
||||
@ -94,7 +108,7 @@ void foo4()
|
||||
A a;
|
||||
tuple<int, double&, const A&> t(1, d, a);
|
||||
const tuple<int, double&, const A> ct = t;
|
||||
|
||||
(void)ct;
|
||||
#ifdef E8
|
||||
get<0>(ct) = 5; // can't assign to const
|
||||
#endif
|
||||
@ -119,9 +133,10 @@ void foo4()
|
||||
|
||||
void foo5() {
|
||||
tuple<char, BB*, BB, DD> t;
|
||||
|
||||
(void)t;
|
||||
tuple<char, char> aaa;
|
||||
tuple<int, int> bbb(aaa);
|
||||
(void)bbb;
|
||||
// tuple<int, AA*, CC, CC> a = t;
|
||||
// a = t;
|
||||
}
|
||||
|
@ -1,3 +1,16 @@
|
||||
// Copyright (C) 1999, 2000 Jaakko J<>rvi (jaakko.jarvi@cs.utu.fi)
|
||||
//
|
||||
// Permission to copy, use, sell and distribute this software is granted
|
||||
// provided this copyright notice appears in all copies.
|
||||
// Permission to modify the code and to distribute modified code is granted
|
||||
// provided this copyright notice appears in all copies, and a notice
|
||||
// that the code was modified is included with the copyright notice.
|
||||
//
|
||||
// This software is provided "as is" without express or implied warranty,
|
||||
// and with no claim as to its suitability for any purpose.
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
// -- io_test.cpp -----------------------------------------------
|
||||
//
|
||||
// Testing the I/O facilities of tuples
|
||||
@ -19,8 +32,6 @@
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
@ -33,7 +44,8 @@ typedef istringstream useThisIStringStream;
|
||||
#endif
|
||||
|
||||
int test_main(int argc, char * argv[] ) {
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
using boost::tuples::set_close;
|
||||
using boost::tuples::set_open;
|
||||
using boost::tuples::set_delimiter;
|
||||
@ -94,7 +106,7 @@ int test_main(int argc, char * argv[] ) {
|
||||
useThisIStringStream is("(100 200 300)");
|
||||
|
||||
tuple<int, int, int> ti;
|
||||
BOOST_TEST(is >> ti);
|
||||
BOOST_TEST(bool(is >> ti));
|
||||
BOOST_TEST(ti == make_tuple(100, 200, 300));
|
||||
|
||||
|
||||
|
@ -1,3 +1,16 @@
|
||||
// Copyright (C) 1999, 2000 Jaakko J<>rvi (jaakko.jarvi@cs.utu.fi)
|
||||
//
|
||||
// Permission to copy, use, sell and distribute this software is granted
|
||||
// provided this copyright notice appears in all copies.
|
||||
// Permission to modify the code and to distribute modified code is granted
|
||||
// provided this copyright notice appears in all copies, and a notice
|
||||
// that the code was modified is included with the copyright notice.
|
||||
//
|
||||
// This software is provided "as is" without express or implied warranty,
|
||||
// and with no claim as to its suitability for any purpose.
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
// tuple_test_bench.cpp --------------------------------
|
||||
|
||||
#define BOOST_INCLUDE_MAIN // for testing, include rather than link
|
||||
@ -297,7 +310,7 @@ make_tuple_test()
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
A a; B b;
|
||||
A a = A(); B b;
|
||||
const A ca = a;
|
||||
make_tuple(cref(a), b);
|
||||
make_tuple(ref(a), b);
|
||||
|
Reference in New Issue
Block a user