forked from boostorg/utility
Compare commits
4 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
|
df2ef006c7 | ||
|
22d30b566b | ||
|
4476a85d55 | ||
|
f02dc90bfc |
263
counting_iterator_test.cpp
Normal file
263
counting_iterator_test.cpp
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
// (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
||||||
|
// distribute this software is granted provided this copyright notice appears in
|
||||||
|
// all copies. This software is provided "as is" without express or implied
|
||||||
|
// warranty, and with no claim as to its suitability for any purpose.
|
||||||
|
//
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
//
|
||||||
|
// Revision History
|
||||||
|
// 16 Feb 2001 Added a missing const. Made the tests run (somewhat) with
|
||||||
|
// plain MSVC again. (David Abrahams)
|
||||||
|
// 11 Feb 2001 #if 0'd out use of counting_iterator on non-numeric types in
|
||||||
|
// MSVC without STLport, so that the other tests may proceed
|
||||||
|
// (David Abrahams)
|
||||||
|
// 04 Feb 2001 Added use of iterator_tests.hpp (David Abrahams)
|
||||||
|
// 28 Jan 2001 Removed not_an_iterator detritus (David Abrahams)
|
||||||
|
// 24 Jan 2001 Initial revision (David Abrahams)
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
# pragma warning(disable:4786) // identifier truncated in debug info
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <boost/pending/iterator_tests.hpp>
|
||||||
|
#include <boost/counting_iterator.hpp>
|
||||||
|
#include <boost/detail/iterator.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
#include <climits>
|
||||||
|
#include <iterator>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <boost/utility.hpp>
|
||||||
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
|
#include <cassert>
|
||||||
|
#ifndef BOOST_NO_LIMITS
|
||||||
|
# include <limits>
|
||||||
|
#endif
|
||||||
|
#ifndef BOOST_NO_SLIST
|
||||||
|
# include <slist>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <class T> struct is_numeric
|
||||||
|
{
|
||||||
|
enum { value =
|
||||||
|
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||||
|
std::numeric_limits<T>::is_specialized
|
||||||
|
#else
|
||||||
|
// Causes warnings with GCC, but how else can I detect numeric types at
|
||||||
|
// compile-time?
|
||||||
|
(boost::is_convertible<int,T>::value &&
|
||||||
|
boost::is_convertible<T,int>::value)
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Special tests for RandomAccess CountingIterators.
|
||||||
|
template <class CountingIterator>
|
||||||
|
void category_test(
|
||||||
|
CountingIterator start,
|
||||||
|
CountingIterator finish,
|
||||||
|
std::random_access_iterator_tag)
|
||||||
|
{
|
||||||
|
typedef typename
|
||||||
|
boost::detail::iterator_traits<CountingIterator>::difference_type
|
||||||
|
difference_type;
|
||||||
|
difference_type distance = boost::detail::distance(start, finish);
|
||||||
|
|
||||||
|
// Pick a random position internal to the range
|
||||||
|
difference_type offset = (unsigned)rand() % distance;
|
||||||
|
assert(offset >= 0);
|
||||||
|
CountingIterator internal = start;
|
||||||
|
std::advance(internal, offset);
|
||||||
|
|
||||||
|
// Try some binary searches on the range to show that it's ordered
|
||||||
|
assert(std::binary_search(start, finish, *internal));
|
||||||
|
CountingIterator x,y;
|
||||||
|
boost::tie(x,y) = std::equal_range(start, finish, *internal);
|
||||||
|
assert(boost::detail::distance(x, y) == 1);
|
||||||
|
|
||||||
|
// Show that values outside the range can't be found
|
||||||
|
assert(!std::binary_search(start, boost::prior(finish), *finish));
|
||||||
|
|
||||||
|
// Do the generic random_access_iterator_test
|
||||||
|
typedef typename CountingIterator::value_type value_type;
|
||||||
|
std::vector<value_type> v;
|
||||||
|
for (value_type z = *start; z != *finish; ++z)
|
||||||
|
v.push_back(z);
|
||||||
|
if (v.size() >= 2)
|
||||||
|
{
|
||||||
|
// Note that this test requires a that the first argument is
|
||||||
|
// dereferenceable /and/ a valid iterator prior to the first argument
|
||||||
|
boost::random_access_iterator_test(start + 1, v.size() - 1, v.begin() + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special tests for bidirectional CountingIterators
|
||||||
|
template <class CountingIterator>
|
||||||
|
void category_test(CountingIterator start, CountingIterator finish, std::bidirectional_iterator_tag)
|
||||||
|
{
|
||||||
|
if (finish != start
|
||||||
|
&& finish != boost::next(start)
|
||||||
|
&& finish != boost::next(boost::next(start)))
|
||||||
|
{
|
||||||
|
// Note that this test requires a that the first argument is
|
||||||
|
// dereferenceable /and/ a valid iterator prior to the first argument
|
||||||
|
boost::bidirectional_iterator_test(boost::next(start), boost::next(*start), boost::next(boost::next(*start)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class CountingIterator>
|
||||||
|
void category_test(CountingIterator start, CountingIterator finish, std::forward_iterator_tag)
|
||||||
|
{
|
||||||
|
if (finish != start && finish != boost::next(start))
|
||||||
|
boost::forward_iterator_test(start, *start, boost::next(*start));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class CountingIterator>
|
||||||
|
void test_aux(CountingIterator start, CountingIterator finish)
|
||||||
|
{
|
||||||
|
typedef typename CountingIterator::iterator_category category;
|
||||||
|
typedef typename CountingIterator::value_type value_type;
|
||||||
|
|
||||||
|
// If it's a RandomAccessIterator we can do a few delicate tests
|
||||||
|
category_test(start, finish, category());
|
||||||
|
|
||||||
|
// Okay, brute force...
|
||||||
|
for (CountingIterator p = start; p != finish && boost::next(p) != finish; ++p)
|
||||||
|
{
|
||||||
|
assert(boost::next(*p) == *boost::next(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
// prove that a reference can be formed to these values
|
||||||
|
typedef typename CountingIterator::value_type value;
|
||||||
|
const value* q = &*start;
|
||||||
|
(void)q; // suppress unused variable warning
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Incrementable>
|
||||||
|
void test(Incrementable start, Incrementable finish)
|
||||||
|
{
|
||||||
|
test_aux(boost::make_counting_iterator(start), boost::make_counting_iterator(finish));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Integer>
|
||||||
|
void test_integer(Integer* = 0) // default arg works around MSVC bug
|
||||||
|
{
|
||||||
|
Integer start = 0;
|
||||||
|
Integer finish = 120;
|
||||||
|
test(start, finish);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Container>
|
||||||
|
void test_container(Container* = 0) // default arg works around MSVC bug
|
||||||
|
{
|
||||||
|
Container c(1 + (unsigned)rand() % 1673);
|
||||||
|
|
||||||
|
const typename Container::iterator start = c.begin();
|
||||||
|
|
||||||
|
// back off by 1 to leave room for dereferenceable value at the end
|
||||||
|
typename Container::iterator finish = start;
|
||||||
|
std::advance(finish, c.size() - 1);
|
||||||
|
|
||||||
|
test(start, finish);
|
||||||
|
|
||||||
|
typedef typename Container::const_iterator const_iterator;
|
||||||
|
test(const_iterator(start), const_iterator(finish));
|
||||||
|
}
|
||||||
|
|
||||||
|
class my_int1 {
|
||||||
|
public:
|
||||||
|
my_int1() { }
|
||||||
|
my_int1(int x) : m_int(x) { }
|
||||||
|
my_int1& operator++() { ++m_int; return *this; }
|
||||||
|
bool operator==(const my_int1& x) const { return m_int == x.m_int; }
|
||||||
|
private:
|
||||||
|
int m_int;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
template <>
|
||||||
|
struct counting_iterator_traits<my_int1> {
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class my_int2 {
|
||||||
|
public:
|
||||||
|
typedef void value_type;
|
||||||
|
typedef void pointer;
|
||||||
|
typedef void reference;
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
typedef std::bidirectional_iterator_tag iterator_category;
|
||||||
|
|
||||||
|
my_int2() { }
|
||||||
|
my_int2(int x) : m_int(x) { }
|
||||||
|
my_int2& operator++() { ++m_int; return *this; }
|
||||||
|
my_int2& operator--() { --m_int; return *this; }
|
||||||
|
bool operator==(const my_int2& x) const { return m_int == x.m_int; }
|
||||||
|
private:
|
||||||
|
int m_int;
|
||||||
|
};
|
||||||
|
|
||||||
|
class my_int3 {
|
||||||
|
public:
|
||||||
|
typedef void value_type;
|
||||||
|
typedef void pointer;
|
||||||
|
typedef void reference;
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
typedef std::random_access_iterator_tag iterator_category;
|
||||||
|
|
||||||
|
my_int3() { }
|
||||||
|
my_int3(int x) : m_int(x) { }
|
||||||
|
my_int3& operator++() { ++m_int; return *this; }
|
||||||
|
my_int3& operator+=(std::ptrdiff_t n) { m_int += n; return *this; }
|
||||||
|
std::ptrdiff_t operator-(const my_int3& x) const { return m_int - x.m_int; }
|
||||||
|
my_int3& operator--() { --m_int; return *this; }
|
||||||
|
bool operator==(const my_int3& x) const { return m_int == x.m_int; }
|
||||||
|
bool operator!=(const my_int3& x) const { return m_int != x.m_int; }
|
||||||
|
bool operator<(const my_int3& x) const { return m_int < x.m_int; }
|
||||||
|
private:
|
||||||
|
int m_int;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Test the built-in integer types.
|
||||||
|
test_integer<char>();
|
||||||
|
test_integer<unsigned char>();
|
||||||
|
test_integer<signed char>();
|
||||||
|
test_integer<wchar_t>();
|
||||||
|
test_integer<short>();
|
||||||
|
test_integer<unsigned short>();
|
||||||
|
test_integer<int>();
|
||||||
|
test_integer<unsigned int>();
|
||||||
|
test_integer<long>();
|
||||||
|
test_integer<unsigned long>();
|
||||||
|
#if defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)
|
||||||
|
test_integer<long long>();
|
||||||
|
test_integer<unsigned long long>();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// wrapping an iterator or non-built-in integer type causes an INTERNAL
|
||||||
|
// COMPILER ERROR in MSVC without STLport. I'm clueless as to why.
|
||||||
|
#if !defined(BOOST_MSVC) || defined(__SGI_STL_PORT)
|
||||||
|
// Test user-defined type.
|
||||||
|
test_integer<my_int1>();
|
||||||
|
test_integer<my_int2>();
|
||||||
|
test_integer<my_int3>();
|
||||||
|
|
||||||
|
// Some tests on container iterators, to prove we handle a few different categories
|
||||||
|
test_container<std::vector<int> >();
|
||||||
|
test_container<std::list<int> >();
|
||||||
|
# ifndef BOOST_NO_SLIST
|
||||||
|
test_container<BOOST_STD_EXTENSION_NAMESPACE::slist<int> >();
|
||||||
|
# endif
|
||||||
|
|
||||||
|
// Also prove that we can handle raw pointers.
|
||||||
|
int array[2000];
|
||||||
|
test(boost::make_counting_iterator(array), boost::make_counting_iterator(array+2000-1));
|
||||||
|
#endif
|
||||||
|
std::cout << "test successful " << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
41
fun_out_iter_example.cpp
Normal file
41
fun_out_iter_example.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// (C) Copyright Jeremy Siek 2001. Permission to copy, use, modify,
|
||||||
|
// sell and distribute this software is granted provided this
|
||||||
|
// copyright notice appears in all copies. This software is provided
|
||||||
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
|
// to its suitability for any purpose.
|
||||||
|
|
||||||
|
// Revision History:
|
||||||
|
|
||||||
|
// 27 Feb 2001 Jeremy Siek
|
||||||
|
// Initial checkin.
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/function_output_iterator.hpp>
|
||||||
|
|
||||||
|
struct string_appender {
|
||||||
|
string_appender(std::string& s) : m_str(s) { }
|
||||||
|
void operator()(const std::string& x) const {
|
||||||
|
m_str += x;
|
||||||
|
}
|
||||||
|
std::string& m_str;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int, char*[])
|
||||||
|
{
|
||||||
|
std::vector<std::string> x;
|
||||||
|
x.push_back("hello");
|
||||||
|
x.push_back(" ");
|
||||||
|
x.push_back("world");
|
||||||
|
x.push_back("!");
|
||||||
|
|
||||||
|
std::string s = "";
|
||||||
|
std::copy(x.begin(), x.end(),
|
||||||
|
boost::make_function_output_iterator(string_appender(s)));
|
||||||
|
|
||||||
|
std::cout << s << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
169
function_output_iterator.htm
Normal file
169
function_output_iterator.htm
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||||
|
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
|
||||||
|
<meta name="ProgId" content="FrontPage.Editor.Document">
|
||||||
|
|
||||||
|
<title>Function Output Iterator Adaptor Documentation</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="#FFFFFF" text="#000000">
|
||||||
|
|
||||||
|
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align=
|
||||||
|
"center" width="277" height="86">
|
||||||
|
|
||||||
|
<h1>Function Output Iterator Adaptor</h1>
|
||||||
|
Defined in header <a href=
|
||||||
|
"../../boost/function_output_iterator.hpp">boost/function_output_iterator.hpp</a>
|
||||||
|
|
||||||
|
<p>The function output iterator adaptor makes it easier to create
|
||||||
|
custom output iterators. The adaptor takes a <a
|
||||||
|
href="http://www.sgi.com/tech/stl/UnaryFunction.html">Unary
|
||||||
|
Function</a> and creates a model of <a
|
||||||
|
href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
|
||||||
|
Iterator</a>. Each item assigned to the output iterator is passed
|
||||||
|
as an argument to the unary function. The motivation for this
|
||||||
|
iterator is that creating a C++ Standard conforming output
|
||||||
|
iterator is non-trivial, particularly because the proper
|
||||||
|
implementation usually requires a proxy object. On the other hand,
|
||||||
|
creating a function (or function object) is much simpler.
|
||||||
|
|
||||||
|
<h2>Synopsis</h2>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<pre>
|
||||||
|
namespace boost {
|
||||||
|
template <class UnaryFunction>
|
||||||
|
class function_output_iterator;
|
||||||
|
|
||||||
|
template <class UnaryFunction>
|
||||||
|
function_output_iterator<UnaryFunction>
|
||||||
|
make_function_output_iterator(const UnaryFunction& f = UnaryFunction())
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<h3>Example</h3>
|
||||||
|
|
||||||
|
In this example we create an output iterator that appends
|
||||||
|
each item onto the end of a string, using the <tt>string_appender</tt>
|
||||||
|
function.
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<pre>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/function_output_iterator.hpp>
|
||||||
|
|
||||||
|
struct string_appender {
|
||||||
|
string_appender(std::string& s) : m_str(s) { }
|
||||||
|
void operator()(const std::string& x) const {
|
||||||
|
m_str += x;
|
||||||
|
}
|
||||||
|
std::string& m_str;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int, char*[])
|
||||||
|
{
|
||||||
|
std::vector<std::string> x;
|
||||||
|
x.push_back("hello");
|
||||||
|
x.push_back(" ");
|
||||||
|
x.push_back("world");
|
||||||
|
x.push_back("!");
|
||||||
|
|
||||||
|
std::string s = "";
|
||||||
|
std::copy(x.begin(), x.end(),
|
||||||
|
boost::make_function_output_iterator(string_appender(s)));
|
||||||
|
|
||||||
|
std::cout << s << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2><a name="function_output_iterator">The Function Output Iterator Class</a></h2>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<pre>
|
||||||
|
template <class UnaryFunction>
|
||||||
|
class function_output_iterator;
|
||||||
|
</pre>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
The <tt>function_output_iterator</tt> class creates an <a
|
||||||
|
href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
|
||||||
|
Iterator</a> out of a
|
||||||
|
<a href="http://www.sgi.com/tech/stl/UnaryFunction.html">Unary
|
||||||
|
Function</a>. Each item assigned to the output iterator is passed
|
||||||
|
as an argument to the unary function.
|
||||||
|
|
||||||
|
<h3>Template Parameters</h3>
|
||||||
|
|
||||||
|
<table border>
|
||||||
|
<tr>
|
||||||
|
<th>Parameter
|
||||||
|
|
||||||
|
<th>Description
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><tt>UnaryFunction</tt>
|
||||||
|
|
||||||
|
<td>The function type being wrapped. The return type of the
|
||||||
|
function is not used, so it can be <tt>void</tt>. The
|
||||||
|
function must be a model of <a
|
||||||
|
href="http://www.sgi.com/tech/stl/UnaryFunction.html">Unary
|
||||||
|
Function</a>.</td>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Concept Model</h3>
|
||||||
|
The function output iterator class is a model of <a
|
||||||
|
href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
|
||||||
|
Iterator</a>.
|
||||||
|
|
||||||
|
<h2>Members</h3>
|
||||||
|
The function output iterator implements the member functions
|
||||||
|
and operators required of the <a
|
||||||
|
href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
|
||||||
|
Iterator</a> concept. In addition it has the following constructor:
|
||||||
|
<pre>
|
||||||
|
explicit function_output_iterator(const UnaryFunction& f = UnaryFunction())
|
||||||
|
</pre>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<h2><a name="make_function_output_iterator">The Function Output Iterator Object
|
||||||
|
Generator</a></h2>
|
||||||
|
|
||||||
|
The <tt>make_function_output_iterator()</tt> function provides a
|
||||||
|
more convenient way to create function output iterator objects. The
|
||||||
|
function saves the user the trouble of explicitly writing out the
|
||||||
|
iterator types. If the default argument is used, the function
|
||||||
|
type must be provided as an explicit template argument.
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<pre>
|
||||||
|
template <class UnaryFunction>
|
||||||
|
function_output_iterator<UnaryFunction>
|
||||||
|
make_function_output_iterator(const UnaryFunction& f = UnaryFunction())
|
||||||
|
</pre>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>© Copyright Jeremy Siek 2001. Permission to copy, use,
|
||||||
|
modify, sell and distribute this document is granted provided this
|
||||||
|
copyright notice appears in all copies. This document is provided
|
||||||
|
"as is" without express or implied warranty, and with no claim as
|
||||||
|
to its suitability for any purpose.
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@@ -1,37 +0,0 @@
|
|||||||
//
|
|
||||||
// boost/assert.hpp - BOOST_ASSERT(expr)
|
|
||||||
//
|
|
||||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
|
||||||
//
|
|
||||||
// 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)
|
|
||||||
//
|
|
||||||
// Note: There are no include guards. This is intentional.
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/utility/assert.html for documentation.
|
|
||||||
//
|
|
||||||
|
|
||||||
#undef BOOST_ASSERT
|
|
||||||
|
|
||||||
#if defined(BOOST_DISABLE_ASSERTS)
|
|
||||||
|
|
||||||
# define BOOST_ASSERT(expr) ((void)0)
|
|
||||||
|
|
||||||
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
|
|
||||||
|
|
||||||
#include <boost/current_function.hpp>
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
|
||||||
|
|
||||||
#else
|
|
||||||
# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
|
|
||||||
# define BOOST_ASSERT(expr) assert(expr)
|
|
||||||
#endif
|
|
@@ -1,24 +0,0 @@
|
|||||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
|
||||||
// Use, modification and distribution are subject to 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).
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
|
||||||
|
|
||||||
// See boost/detail/call_traits.hpp and boost/detail/ob_call_traits.hpp
|
|
||||||
// for full copyright notices.
|
|
||||||
|
|
||||||
#ifndef BOOST_CALL_TRAITS_HPP
|
|
||||||
#define BOOST_CALL_TRAITS_HPP
|
|
||||||
|
|
||||||
#ifndef BOOST_CONFIG_HPP
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
#include <boost/detail/ob_call_traits.hpp>
|
|
||||||
#else
|
|
||||||
#include <boost/detail/call_traits.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // BOOST_CALL_TRAITS_HPP
|
|
@@ -1,69 +0,0 @@
|
|||||||
#ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
|
|
||||||
#define BOOST_CHECKED_DELETE_HPP_INCLUDED
|
|
||||||
|
|
||||||
// MS compatible compilers support #pragma once
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
|
||||||
// boost/checked_delete.hpp
|
|
||||||
//
|
|
||||||
// Copyright (c) 2002, 2003 Peter Dimov
|
|
||||||
// Copyright (c) 2003 Daniel Frey
|
|
||||||
// Copyright (c) 2003 Howard Hinnant
|
|
||||||
//
|
|
||||||
// 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)
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/utility/checked_delete.html for documentation.
|
|
||||||
//
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
// verify that types are complete for increased safety
|
|
||||||
|
|
||||||
template<class T> inline void checked_delete(T * x)
|
|
||||||
{
|
|
||||||
// intentionally complex - simplification causes regressions
|
|
||||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
|
||||||
(void) sizeof(type_must_be_complete);
|
|
||||||
delete x;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T> inline void checked_array_delete(T * x)
|
|
||||||
{
|
|
||||||
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
|
|
||||||
(void) sizeof(type_must_be_complete);
|
|
||||||
delete [] x;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T> struct checked_deleter
|
|
||||||
{
|
|
||||||
typedef void result_type;
|
|
||||||
typedef T * argument_type;
|
|
||||||
|
|
||||||
void operator()(T * x) const
|
|
||||||
{
|
|
||||||
// boost:: disables ADL
|
|
||||||
boost::checked_delete(x);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T> struct checked_array_deleter
|
|
||||||
{
|
|
||||||
typedef void result_type;
|
|
||||||
typedef T * argument_type;
|
|
||||||
|
|
||||||
void operator()(T * x) const
|
|
||||||
{
|
|
||||||
boost::checked_array_delete(x);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
|
|
@@ -1,24 +0,0 @@
|
|||||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
|
||||||
// Use, modification and distribution are subject to 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).
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
|
||||||
|
|
||||||
// See boost/detail/compressed_pair.hpp and boost/detail/ob_compressed_pair.hpp
|
|
||||||
// for full copyright notices.
|
|
||||||
|
|
||||||
#ifndef BOOST_COMPRESSED_PAIR_HPP
|
|
||||||
#define BOOST_COMPRESSED_PAIR_HPP
|
|
||||||
|
|
||||||
#ifndef BOOST_CONFIG_HPP
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
#include <boost/detail/ob_compressed_pair.hpp>
|
|
||||||
#else
|
|
||||||
#include <boost/detail/compressed_pair.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // BOOST_COMPRESSED_PAIR_HPP
|
|
@@ -1,63 +0,0 @@
|
|||||||
#ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
|
||||||
#define BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
|
||||||
|
|
||||||
// MS compatible compilers support #pragma once
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
|
||||||
// boost/current_function.hpp - BOOST_CURRENT_FUNCTION
|
|
||||||
//
|
|
||||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
|
||||||
//
|
|
||||||
// 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)
|
|
||||||
//
|
|
||||||
// http://www.boost.org/libs/utility/current_function.html
|
|
||||||
//
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
inline void current_function_helper()
|
|
||||||
{
|
|
||||||
|
|
||||||
#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600))
|
|
||||||
|
|
||||||
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
|
||||||
|
|
||||||
#elif defined(__FUNCSIG__)
|
|
||||||
|
|
||||||
# define BOOST_CURRENT_FUNCTION __FUNCSIG__
|
|
||||||
|
|
||||||
#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
|
|
||||||
|
|
||||||
# define BOOST_CURRENT_FUNCTION __FUNCTION__
|
|
||||||
|
|
||||||
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
|
|
||||||
|
|
||||||
# define BOOST_CURRENT_FUNCTION __FUNC__
|
|
||||||
|
|
||||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
|
|
||||||
|
|
||||||
# define BOOST_CURRENT_FUNCTION __func__
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
# define BOOST_CURRENT_FUNCTION "(unknown)"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif // #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
|
@@ -1,155 +0,0 @@
|
|||||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
|
||||||
// Use, modification and distribution are subject to 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).
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
|
||||||
|
|
||||||
// call_traits: defines typedefs for function usage
|
|
||||||
// (see libs/utility/call_traits.htm)
|
|
||||||
|
|
||||||
/* Release notes:
|
|
||||||
23rd July 2000:
|
|
||||||
Fixed array specialization. (JM)
|
|
||||||
Added Borland specific fixes for reference types
|
|
||||||
(issue raised by Steve Cleary).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BOOST_DETAIL_CALL_TRAITS_HPP
|
|
||||||
#define BOOST_DETAIL_CALL_TRAITS_HPP
|
|
||||||
|
|
||||||
#ifndef BOOST_CONFIG_HPP
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#endif
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
#include <boost/type_traits/is_arithmetic.hpp>
|
|
||||||
#include <boost/type_traits/is_pointer.hpp>
|
|
||||||
#include <boost/detail/workaround.hpp>
|
|
||||||
|
|
||||||
namespace boost{
|
|
||||||
|
|
||||||
namespace detail{
|
|
||||||
|
|
||||||
template <typename T, bool small_>
|
|
||||||
struct ct_imp2
|
|
||||||
{
|
|
||||||
typedef const T& param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct ct_imp2<T, true>
|
|
||||||
{
|
|
||||||
typedef const T param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, bool isp, bool b1>
|
|
||||||
struct ct_imp
|
|
||||||
{
|
|
||||||
typedef const T& param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, bool isp>
|
|
||||||
struct ct_imp<T, isp, true>
|
|
||||||
{
|
|
||||||
typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, bool b1>
|
|
||||||
struct ct_imp<T, true, b1>
|
|
||||||
{
|
|
||||||
typedef T const param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct call_traits
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef const T& const_reference;
|
|
||||||
//
|
|
||||||
// C++ Builder workaround: we should be able to define a compile time
|
|
||||||
// constant and pass that as a single template parameter to ct_imp<T,bool>,
|
|
||||||
// however compiler bugs prevent this - instead pass three bool's to
|
|
||||||
// ct_imp<T,bool,bool,bool> and add an extra partial specialisation
|
|
||||||
// of ct_imp to handle the logic. (JM)
|
|
||||||
typedef typename boost::detail::ct_imp<
|
|
||||||
T,
|
|
||||||
::boost::is_pointer<T>::value,
|
|
||||||
::boost::is_arithmetic<T>::value
|
|
||||||
>::param_type param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct call_traits<T&>
|
|
||||||
{
|
|
||||||
typedef T& value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef const T& const_reference;
|
|
||||||
typedef T& param_type; // hh removed const
|
|
||||||
};
|
|
||||||
|
|
||||||
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x570 ) )
|
|
||||||
// these are illegal specialisations; cv-qualifies applied to
|
|
||||||
// references have no effect according to [8.3.2p1],
|
|
||||||
// C++ Builder requires them though as it treats cv-qualified
|
|
||||||
// references as distinct types...
|
|
||||||
template <typename T>
|
|
||||||
struct call_traits<T&const>
|
|
||||||
{
|
|
||||||
typedef T& value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef const T& const_reference;
|
|
||||||
typedef T& param_type; // hh removed const
|
|
||||||
};
|
|
||||||
template <typename T>
|
|
||||||
struct call_traits<T&volatile>
|
|
||||||
{
|
|
||||||
typedef T& value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef const T& const_reference;
|
|
||||||
typedef T& param_type; // hh removed const
|
|
||||||
};
|
|
||||||
template <typename T>
|
|
||||||
struct call_traits<T&const volatile>
|
|
||||||
{
|
|
||||||
typedef T& value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef const T& const_reference;
|
|
||||||
typedef T& param_type; // hh removed const
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
|
|
||||||
template <typename T, std::size_t N>
|
|
||||||
struct call_traits<T [N]>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
typedef T array_type[N];
|
|
||||||
public:
|
|
||||||
// degrades array to pointer:
|
|
||||||
typedef const T* value_type;
|
|
||||||
typedef array_type& reference;
|
|
||||||
typedef const array_type& const_reference;
|
|
||||||
typedef const T* const param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
|
||||||
struct call_traits<const T [N]>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
typedef const T array_type[N];
|
|
||||||
public:
|
|
||||||
// degrades array to pointer:
|
|
||||||
typedef const T* value_type;
|
|
||||||
typedef array_type& reference;
|
|
||||||
typedef const array_type& const_reference;
|
|
||||||
typedef const T* const param_type;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BOOST_DETAIL_CALL_TRAITS_HPP
|
|
@@ -1,432 +0,0 @@
|
|||||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
|
||||||
// Use, modification and distribution are subject to 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).
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
|
||||||
|
|
||||||
// compressed_pair: pair that "compresses" empty members
|
|
||||||
// (see libs/utility/compressed_pair.htm)
|
|
||||||
//
|
|
||||||
// JM changes 25 Jan 2004:
|
|
||||||
// For the case where T1 == T2 and both are empty, then first() and second()
|
|
||||||
// should return different objects.
|
|
||||||
// JM changes 25 Jan 2000:
|
|
||||||
// Removed default arguments from compressed_pair_switch to get
|
|
||||||
// C++ Builder 4 to accept them
|
|
||||||
// rewriten swap to get gcc and C++ builder to compile.
|
|
||||||
// added partial specialisations for case T1 == T2 to avoid duplicate constructor defs.
|
|
||||||
|
|
||||||
#ifndef BOOST_DETAIL_COMPRESSED_PAIR_HPP
|
|
||||||
#define BOOST_DETAIL_COMPRESSED_PAIR_HPP
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include <boost/type_traits/remove_cv.hpp>
|
|
||||||
#include <boost/type_traits/is_empty.hpp>
|
|
||||||
#include <boost/type_traits/is_same.hpp>
|
|
||||||
#include <boost/call_traits.hpp>
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair;
|
|
||||||
|
|
||||||
|
|
||||||
// compressed_pair
|
|
||||||
|
|
||||||
namespace details
|
|
||||||
{
|
|
||||||
// JM altered 26 Jan 2000:
|
|
||||||
template <class T1, class T2, bool IsSame, bool FirstEmpty, bool SecondEmpty>
|
|
||||||
struct compressed_pair_switch;
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct compressed_pair_switch<T1, T2, false, false, false>
|
|
||||||
{static const int value = 0;};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct compressed_pair_switch<T1, T2, false, true, true>
|
|
||||||
{static const int value = 3;};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct compressed_pair_switch<T1, T2, false, true, false>
|
|
||||||
{static const int value = 1;};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct compressed_pair_switch<T1, T2, false, false, true>
|
|
||||||
{static const int value = 2;};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct compressed_pair_switch<T1, T2, true, true, true>
|
|
||||||
{static const int value = 4;};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct compressed_pair_switch<T1, T2, true, false, false>
|
|
||||||
{static const int value = 5;};
|
|
||||||
|
|
||||||
template <class T1, class T2, int Version> class compressed_pair_imp;
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
// workaround for GCC (JM):
|
|
||||||
using std::swap;
|
|
||||||
#endif
|
|
||||||
//
|
|
||||||
// can't call unqualified swap from within classname::swap
|
|
||||||
// as Koenig lookup rules will find only the classname::swap
|
|
||||||
// member function not the global declaration, so use cp_swap
|
|
||||||
// as a forwarding function (JM):
|
|
||||||
template <typename T>
|
|
||||||
inline void cp_swap(T& t1, T& t2)
|
|
||||||
{
|
|
||||||
#ifndef __GNUC__
|
|
||||||
using std::swap;
|
|
||||||
#endif
|
|
||||||
swap(t1, t2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 0 derive from neither
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_imp<T1, T2, 0>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_imp() {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x, second_param_type y)
|
|
||||||
: first_(x), second_(y) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x)
|
|
||||||
: first_(x) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(second_param_type y)
|
|
||||||
: second_(y) {}
|
|
||||||
|
|
||||||
first_reference first() {return first_;}
|
|
||||||
first_const_reference first() const {return first_;}
|
|
||||||
|
|
||||||
second_reference second() {return second_;}
|
|
||||||
second_const_reference second() const {return second_;}
|
|
||||||
|
|
||||||
void swap(::boost::compressed_pair<T1, T2>& y)
|
|
||||||
{
|
|
||||||
cp_swap(first_, y.first());
|
|
||||||
cp_swap(second_, y.second());
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
first_type first_;
|
|
||||||
second_type second_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 1 derive from T1
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_imp<T1, T2, 1>
|
|
||||||
: private ::boost::remove_cv<T1>::type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_imp() {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x, second_param_type y)
|
|
||||||
: first_type(x), second_(y) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x)
|
|
||||||
: first_type(x) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(second_param_type y)
|
|
||||||
: second_(y) {}
|
|
||||||
|
|
||||||
first_reference first() {return *this;}
|
|
||||||
first_const_reference first() const {return *this;}
|
|
||||||
|
|
||||||
second_reference second() {return second_;}
|
|
||||||
second_const_reference second() const {return second_;}
|
|
||||||
|
|
||||||
void swap(::boost::compressed_pair<T1,T2>& y)
|
|
||||||
{
|
|
||||||
// no need to swap empty base class:
|
|
||||||
cp_swap(second_, y.second());
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
second_type second_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 2 derive from T2
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_imp<T1, T2, 2>
|
|
||||||
: private ::boost::remove_cv<T2>::type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_imp() {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x, second_param_type y)
|
|
||||||
: second_type(y), first_(x) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x)
|
|
||||||
: first_(x) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(second_param_type y)
|
|
||||||
: second_type(y) {}
|
|
||||||
|
|
||||||
first_reference first() {return first_;}
|
|
||||||
first_const_reference first() const {return first_;}
|
|
||||||
|
|
||||||
second_reference second() {return *this;}
|
|
||||||
second_const_reference second() const {return *this;}
|
|
||||||
|
|
||||||
void swap(::boost::compressed_pair<T1,T2>& y)
|
|
||||||
{
|
|
||||||
// no need to swap empty base class:
|
|
||||||
cp_swap(first_, y.first());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
first_type first_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 3 derive from T1 and T2
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_imp<T1, T2, 3>
|
|
||||||
: private ::boost::remove_cv<T1>::type,
|
|
||||||
private ::boost::remove_cv<T2>::type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_imp() {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x, second_param_type y)
|
|
||||||
: first_type(x), second_type(y) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x)
|
|
||||||
: first_type(x) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(second_param_type y)
|
|
||||||
: second_type(y) {}
|
|
||||||
|
|
||||||
first_reference first() {return *this;}
|
|
||||||
first_const_reference first() const {return *this;}
|
|
||||||
|
|
||||||
second_reference second() {return *this;}
|
|
||||||
second_const_reference second() const {return *this;}
|
|
||||||
//
|
|
||||||
// no need to swap empty bases:
|
|
||||||
void swap(::boost::compressed_pair<T1,T2>&) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// JM
|
|
||||||
// 4 T1 == T2, T1 and T2 both empty
|
|
||||||
// Note does not actually store an instance of T2 at all -
|
|
||||||
// but reuses T1 base class for both first() and second().
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_imp<T1, T2, 4>
|
|
||||||
: private ::boost::remove_cv<T1>::type
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_imp() {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x, second_param_type y)
|
|
||||||
: first_type(x), m_second(y) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x)
|
|
||||||
: first_type(x), m_second(x) {}
|
|
||||||
|
|
||||||
first_reference first() {return *this;}
|
|
||||||
first_const_reference first() const {return *this;}
|
|
||||||
|
|
||||||
second_reference second() {return m_second;}
|
|
||||||
second_const_reference second() const {return m_second;}
|
|
||||||
|
|
||||||
void swap(::boost::compressed_pair<T1,T2>&) {}
|
|
||||||
private:
|
|
||||||
T2 m_second;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 5 T1 == T2 and are not empty: //JM
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_imp<T1, T2, 5>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_imp() {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x, second_param_type y)
|
|
||||||
: first_(x), second_(y) {}
|
|
||||||
|
|
||||||
compressed_pair_imp(first_param_type x)
|
|
||||||
: first_(x), second_(x) {}
|
|
||||||
|
|
||||||
first_reference first() {return first_;}
|
|
||||||
first_const_reference first() const {return first_;}
|
|
||||||
|
|
||||||
second_reference second() {return second_;}
|
|
||||||
second_const_reference second() const {return second_;}
|
|
||||||
|
|
||||||
void swap(::boost::compressed_pair<T1, T2>& y)
|
|
||||||
{
|
|
||||||
cp_swap(first_, y.first());
|
|
||||||
cp_swap(second_, y.second());
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
first_type first_;
|
|
||||||
second_type second_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // details
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair
|
|
||||||
: private ::boost::details::compressed_pair_imp<T1, T2,
|
|
||||||
::boost::details::compressed_pair_switch<
|
|
||||||
T1,
|
|
||||||
T2,
|
|
||||||
::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
|
|
||||||
::boost::is_empty<T1>::value,
|
|
||||||
::boost::is_empty<T2>::value>::value>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
typedef details::compressed_pair_imp<T1, T2,
|
|
||||||
::boost::details::compressed_pair_switch<
|
|
||||||
T1,
|
|
||||||
T2,
|
|
||||||
::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
|
|
||||||
::boost::is_empty<T1>::value,
|
|
||||||
::boost::is_empty<T2>::value>::value> base;
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair() : base() {}
|
|
||||||
compressed_pair(first_param_type x, second_param_type y) : base(x, y) {}
|
|
||||||
explicit compressed_pair(first_param_type x) : base(x) {}
|
|
||||||
explicit compressed_pair(second_param_type y) : base(y) {}
|
|
||||||
|
|
||||||
first_reference first() {return base::first();}
|
|
||||||
first_const_reference first() const {return base::first();}
|
|
||||||
|
|
||||||
second_reference second() {return base::second();}
|
|
||||||
second_const_reference second() const {return base::second();}
|
|
||||||
|
|
||||||
void swap(compressed_pair& y) { base::swap(y); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// JM
|
|
||||||
// Partial specialisation for case where T1 == T2:
|
|
||||||
//
|
|
||||||
template <class T>
|
|
||||||
class compressed_pair<T, T>
|
|
||||||
: private details::compressed_pair_imp<T, T,
|
|
||||||
::boost::details::compressed_pair_switch<
|
|
||||||
T,
|
|
||||||
T,
|
|
||||||
::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
|
|
||||||
::boost::is_empty<T>::value,
|
|
||||||
::boost::is_empty<T>::value>::value>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
typedef details::compressed_pair_imp<T, T,
|
|
||||||
::boost::details::compressed_pair_switch<
|
|
||||||
T,
|
|
||||||
T,
|
|
||||||
::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
|
|
||||||
::boost::is_empty<T>::value,
|
|
||||||
::boost::is_empty<T>::value>::value> base;
|
|
||||||
public:
|
|
||||||
typedef T first_type;
|
|
||||||
typedef T second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair() : base() {}
|
|
||||||
compressed_pair(first_param_type x, second_param_type y) : base(x, y) {}
|
|
||||||
#if !(defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530))
|
|
||||||
explicit
|
|
||||||
#endif
|
|
||||||
compressed_pair(first_param_type x) : base(x) {}
|
|
||||||
|
|
||||||
first_reference first() {return base::first();}
|
|
||||||
first_const_reference first() const {return base::first();}
|
|
||||||
|
|
||||||
second_reference second() {return base::second();}
|
|
||||||
second_const_reference second() const {return base::second();}
|
|
||||||
|
|
||||||
void swap(::boost::compressed_pair<T,T>& y) { base::swap(y); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
swap(compressed_pair<T1, T2>& x, compressed_pair<T1, T2>& y)
|
|
||||||
{
|
|
||||||
x.swap(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // boost
|
|
||||||
|
|
||||||
#endif // BOOST_DETAIL_COMPRESSED_PAIR_HPP
|
|
||||||
|
|
@@ -1,168 +0,0 @@
|
|||||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
|
||||||
// Use, modification and distribution are subject to 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).
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
|
||||||
//
|
|
||||||
// Crippled version for crippled compilers:
|
|
||||||
// see libs/utility/call_traits.htm
|
|
||||||
//
|
|
||||||
|
|
||||||
/* Release notes:
|
|
||||||
01st October 2000:
|
|
||||||
Fixed call_traits on VC6, using "poor man's partial specialisation",
|
|
||||||
using ideas taken from "Generative programming" by Krzysztof Czarnecki
|
|
||||||
& Ulrich Eisenecker.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BOOST_OB_CALL_TRAITS_HPP
|
|
||||||
#define BOOST_OB_CALL_TRAITS_HPP
|
|
||||||
|
|
||||||
#ifndef BOOST_CONFIG_HPP
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BOOST_ARITHMETIC_TYPE_TRAITS_HPP
|
|
||||||
#include <boost/type_traits/arithmetic_traits.hpp>
|
|
||||||
#endif
|
|
||||||
#ifndef BOOST_COMPOSITE_TYPE_TRAITS_HPP
|
|
||||||
#include <boost/type_traits/composite_traits.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost{
|
|
||||||
|
|
||||||
#ifdef BOOST_MSVC6_MEMBER_TEMPLATES
|
|
||||||
//
|
|
||||||
// use member templates to emulate
|
|
||||||
// partial specialisation:
|
|
||||||
//
|
|
||||||
namespace detail{
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct standard_call_traits
|
|
||||||
{
|
|
||||||
typedef T value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef const T& const_reference;
|
|
||||||
typedef const T& param_type;
|
|
||||||
};
|
|
||||||
template <class T>
|
|
||||||
struct simple_call_traits
|
|
||||||
{
|
|
||||||
typedef T value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef const T& const_reference;
|
|
||||||
typedef const T param_type;
|
|
||||||
};
|
|
||||||
template <class T>
|
|
||||||
struct reference_call_traits
|
|
||||||
{
|
|
||||||
typedef T value_type;
|
|
||||||
typedef T reference;
|
|
||||||
typedef T const_reference;
|
|
||||||
typedef T param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <bool pointer, bool arithmetic, bool reference>
|
|
||||||
struct call_traits_chooser
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef standard_call_traits<T> type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct call_traits_chooser<true, false, false>
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef simple_call_traits<T> type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct call_traits_chooser<false, false, true>
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef reference_call_traits<T> type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <bool size_is_small>
|
|
||||||
struct call_traits_sizeof_chooser2
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct small_rebind
|
|
||||||
{
|
|
||||||
typedef simple_call_traits<T> small_type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct call_traits_sizeof_chooser2<false>
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct small_rebind
|
|
||||||
{
|
|
||||||
typedef standard_call_traits<T> small_type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct call_traits_chooser<false, true, false>
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
enum { sizeof_choice = (sizeof(T) <= sizeof(void*)) };
|
|
||||||
typedef call_traits_sizeof_chooser2<(sizeof(T) <= sizeof(void*))> chooser;
|
|
||||||
typedef typename chooser::template small_rebind<T> bound_type;
|
|
||||||
typedef typename bound_type::small_type type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
template <typename T>
|
|
||||||
struct call_traits
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
typedef detail::call_traits_chooser<
|
|
||||||
::boost::is_pointer<T>::value,
|
|
||||||
::boost::is_arithmetic<T>::value,
|
|
||||||
::boost::is_reference<T>::value
|
|
||||||
> chooser;
|
|
||||||
typedef typename chooser::template rebind<T> bound_type;
|
|
||||||
typedef typename bound_type::type call_traits_type;
|
|
||||||
public:
|
|
||||||
typedef typename call_traits_type::value_type value_type;
|
|
||||||
typedef typename call_traits_type::reference reference;
|
|
||||||
typedef typename call_traits_type::const_reference const_reference;
|
|
||||||
typedef typename call_traits_type::param_type param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
//
|
|
||||||
// sorry call_traits is completely non-functional
|
|
||||||
// blame your broken compiler:
|
|
||||||
//
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct call_traits
|
|
||||||
{
|
|
||||||
typedef T value_type;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef const T& const_reference;
|
|
||||||
typedef const T& param_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // member templates
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BOOST_OB_CALL_TRAITS_HPP
|
|
@@ -1,510 +0,0 @@
|
|||||||
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
|
|
||||||
// Use, modification and distribution are subject to 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).
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/utility for most recent version including documentation.
|
|
||||||
// see libs/utility/compressed_pair.hpp
|
|
||||||
//
|
|
||||||
/* Release notes:
|
|
||||||
20 Jan 2001:
|
|
||||||
Fixed obvious bugs (David Abrahams)
|
|
||||||
07 Oct 2000:
|
|
||||||
Added better single argument constructor support.
|
|
||||||
03 Oct 2000:
|
|
||||||
Added VC6 support (JM).
|
|
||||||
23rd July 2000:
|
|
||||||
Additional comments added. (JM)
|
|
||||||
Jan 2000:
|
|
||||||
Original version: this version crippled for use with crippled compilers
|
|
||||||
- John Maddock Jan 2000.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BOOST_OB_COMPRESSED_PAIR_HPP
|
|
||||||
#define BOOST_OB_COMPRESSED_PAIR_HPP
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#ifndef BOOST_OBJECT_TYPE_TRAITS_HPP
|
|
||||||
#include <boost/type_traits/object_traits.hpp>
|
|
||||||
#endif
|
|
||||||
#ifndef BOOST_SAME_TRAITS_HPP
|
|
||||||
#include <boost/type_traits/same_traits.hpp>
|
|
||||||
#endif
|
|
||||||
#ifndef BOOST_CALL_TRAITS_HPP
|
|
||||||
#include <boost/call_traits.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
#ifdef BOOST_MSVC6_MEMBER_TEMPLATES
|
|
||||||
//
|
|
||||||
// use member templates to emulate
|
|
||||||
// partial specialisation. Note that due to
|
|
||||||
// problems with overload resolution with VC6
|
|
||||||
// each of the compressed_pair versions that follow
|
|
||||||
// have one template single-argument constructor
|
|
||||||
// in place of two specific constructors:
|
|
||||||
//
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair;
|
|
||||||
|
|
||||||
namespace detail{
|
|
||||||
|
|
||||||
template <class A, class T1, class T2>
|
|
||||||
struct best_conversion_traits
|
|
||||||
{
|
|
||||||
typedef char one;
|
|
||||||
typedef char (&two)[2];
|
|
||||||
static A a;
|
|
||||||
static one test(T1);
|
|
||||||
static two test(T2);
|
|
||||||
|
|
||||||
enum { value = sizeof(test(a)) };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <int>
|
|
||||||
struct init_one;
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct init_one<1>
|
|
||||||
{
|
|
||||||
template <class A, class T1, class T2>
|
|
||||||
static void init(const A& a, T1* p1, T2*)
|
|
||||||
{
|
|
||||||
*p1 = a;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct init_one<2>
|
|
||||||
{
|
|
||||||
template <class A, class T1, class T2>
|
|
||||||
static void init(const A& a, T1*, T2* p2)
|
|
||||||
{
|
|
||||||
*p2 = a;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// T1 != T2, both non-empty
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_0
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
T1 _first;
|
|
||||||
T2 _second;
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_0() : _first(), _second() {}
|
|
||||||
compressed_pair_0(first_param_type x, second_param_type y) : _first(x), _second(y) {}
|
|
||||||
template <class A>
|
|
||||||
explicit compressed_pair_0(const A& val)
|
|
||||||
{
|
|
||||||
init_one<best_conversion_traits<A, T1, T2>::value>::init(val, &_first, &_second);
|
|
||||||
}
|
|
||||||
compressed_pair_0(const ::boost::compressed_pair<T1,T2>& x)
|
|
||||||
: _first(x.first()), _second(x.second()) {}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
compressed_pair_0& operator=(const compressed_pair_0& x) {
|
|
||||||
cout << "assigning compressed pair 0" << endl;
|
|
||||||
_first = x._first;
|
|
||||||
_second = x._second;
|
|
||||||
cout << "finished assigning compressed pair 0" << endl;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
first_reference first() { return _first; }
|
|
||||||
first_const_reference first() const { return _first; }
|
|
||||||
|
|
||||||
second_reference second() { return _second; }
|
|
||||||
second_const_reference second() const { return _second; }
|
|
||||||
|
|
||||||
void swap(compressed_pair_0& y)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(_first, y._first);
|
|
||||||
swap(_second, y._second);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// T1 != T2, T2 empty
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_1 : T2
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
T1 _first;
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_1() : T2(), _first() {}
|
|
||||||
compressed_pair_1(first_param_type x, second_param_type y) : T2(y), _first(x) {}
|
|
||||||
|
|
||||||
template <class A>
|
|
||||||
explicit compressed_pair_1(const A& val)
|
|
||||||
{
|
|
||||||
init_one<best_conversion_traits<A, T1, T2>::value>::init(val, &_first, static_cast<T2*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
compressed_pair_1(const ::boost::compressed_pair<T1,T2>& x)
|
|
||||||
: T2(x.second()), _first(x.first()) {}
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
|
|
||||||
// Total weirdness. If the assignment to _first is moved after
|
|
||||||
// the call to the inherited operator=, then this breaks graph/test/graph.cpp
|
|
||||||
// by way of iterator_adaptor.
|
|
||||||
compressed_pair_1& operator=(const compressed_pair_1& x) {
|
|
||||||
_first = x._first;
|
|
||||||
T2::operator=(x);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
first_reference first() { return _first; }
|
|
||||||
first_const_reference first() const { return _first; }
|
|
||||||
|
|
||||||
second_reference second() { return *this; }
|
|
||||||
second_const_reference second() const { return *this; }
|
|
||||||
|
|
||||||
void swap(compressed_pair_1& y)
|
|
||||||
{
|
|
||||||
// no need to swap empty base class:
|
|
||||||
using std::swap;
|
|
||||||
swap(_first, y._first);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// T1 != T2, T1 empty
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_2 : T1
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
T2 _second;
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_2() : T1(), _second() {}
|
|
||||||
compressed_pair_2(first_param_type x, second_param_type y) : T1(x), _second(y) {}
|
|
||||||
template <class A>
|
|
||||||
explicit compressed_pair_2(const A& val)
|
|
||||||
{
|
|
||||||
init_one<best_conversion_traits<A, T1, T2>::value>::init(val, static_cast<T1*>(this), &_second);
|
|
||||||
}
|
|
||||||
compressed_pair_2(const ::boost::compressed_pair<T1,T2>& x)
|
|
||||||
: T1(x.first()), _second(x.second()) {}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
compressed_pair_2& operator=(const compressed_pair_2& x) {
|
|
||||||
cout << "assigning compressed pair 2" << endl;
|
|
||||||
T1::operator=(x);
|
|
||||||
_second = x._second;
|
|
||||||
cout << "finished assigning compressed pair 2" << endl;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
first_reference first() { return *this; }
|
|
||||||
first_const_reference first() const { return *this; }
|
|
||||||
|
|
||||||
second_reference second() { return _second; }
|
|
||||||
second_const_reference second() const { return _second; }
|
|
||||||
|
|
||||||
void swap(compressed_pair_2& y)
|
|
||||||
{
|
|
||||||
// no need to swap empty base class:
|
|
||||||
using std::swap;
|
|
||||||
swap(_second, y._second);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// T1 != T2, both empty
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_3 : T1, T2
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_3() : T1(), T2() {}
|
|
||||||
compressed_pair_3(first_param_type x, second_param_type y) : T1(x), T2(y) {}
|
|
||||||
template <class A>
|
|
||||||
explicit compressed_pair_3(const A& val)
|
|
||||||
{
|
|
||||||
init_one<best_conversion_traits<A, T1, T2>::value>::init(val, static_cast<T1*>(this), static_cast<T2*>(this));
|
|
||||||
}
|
|
||||||
compressed_pair_3(const ::boost::compressed_pair<T1,T2>& x)
|
|
||||||
: T1(x.first()), T2(x.second()) {}
|
|
||||||
|
|
||||||
first_reference first() { return *this; }
|
|
||||||
first_const_reference first() const { return *this; }
|
|
||||||
|
|
||||||
second_reference second() { return *this; }
|
|
||||||
second_const_reference second() const { return *this; }
|
|
||||||
|
|
||||||
void swap(compressed_pair_3& y)
|
|
||||||
{
|
|
||||||
// no need to swap empty base classes:
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// T1 == T2, and empty
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_4 : T1
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_4() : T1() {}
|
|
||||||
compressed_pair_4(first_param_type x, second_param_type y) : T1(x), m_second(y) {}
|
|
||||||
// only one single argument constructor since T1 == T2
|
|
||||||
explicit compressed_pair_4(first_param_type x) : T1(x), m_second(x) {}
|
|
||||||
compressed_pair_4(const ::boost::compressed_pair<T1,T2>& x)
|
|
||||||
: T1(x.first()), m_second(x.second()) {}
|
|
||||||
|
|
||||||
first_reference first() { return *this; }
|
|
||||||
first_const_reference first() const { return *this; }
|
|
||||||
|
|
||||||
second_reference second() { return m_second; }
|
|
||||||
second_const_reference second() const { return m_second; }
|
|
||||||
|
|
||||||
void swap(compressed_pair_4& y)
|
|
||||||
{
|
|
||||||
// no need to swap empty base classes:
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
T2 m_second;
|
|
||||||
};
|
|
||||||
|
|
||||||
// T1 == T2, not empty
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair_5
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
T1 _first;
|
|
||||||
T2 _second;
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair_5() : _first(), _second() {}
|
|
||||||
compressed_pair_5(first_param_type x, second_param_type y) : _first(x), _second(y) {}
|
|
||||||
// only one single argument constructor since T1 == T2
|
|
||||||
explicit compressed_pair_5(first_param_type x) : _first(x), _second(x) {}
|
|
||||||
compressed_pair_5(const ::boost::compressed_pair<T1,T2>& c)
|
|
||||||
: _first(c.first()), _second(c.second()) {}
|
|
||||||
|
|
||||||
first_reference first() { return _first; }
|
|
||||||
first_const_reference first() const { return _first; }
|
|
||||||
|
|
||||||
second_reference second() { return _second; }
|
|
||||||
second_const_reference second() const { return _second; }
|
|
||||||
|
|
||||||
void swap(compressed_pair_5& y)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(_first, y._first);
|
|
||||||
swap(_second, y._second);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <bool e1, bool e2, bool same>
|
|
||||||
struct compressed_pair_chooser
|
|
||||||
{
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef compressed_pair_0<T1, T2> type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct compressed_pair_chooser<false, true, false>
|
|
||||||
{
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef compressed_pair_1<T1, T2> type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct compressed_pair_chooser<true, false, false>
|
|
||||||
{
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef compressed_pair_2<T1, T2> type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct compressed_pair_chooser<true, true, false>
|
|
||||||
{
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef compressed_pair_3<T1, T2> type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct compressed_pair_chooser<true, true, true>
|
|
||||||
{
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef compressed_pair_4<T1, T2> type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct compressed_pair_chooser<false, false, true>
|
|
||||||
{
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef compressed_pair_5<T1, T2> type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
struct compressed_pair_traits
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
typedef compressed_pair_chooser<is_empty<T1>::value, is_empty<T2>::value, is_same<T1,T2>::value> chooser;
|
|
||||||
typedef typename chooser::template rebind<T1, T2> bound_type;
|
|
||||||
public:
|
|
||||||
typedef typename bound_type::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair : public detail::compressed_pair_traits<T1, T2>::type
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
typedef typename detail::compressed_pair_traits<T1, T2>::type base_type;
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair() : base_type() {}
|
|
||||||
compressed_pair(first_param_type x, second_param_type y) : base_type(x, y) {}
|
|
||||||
template <class A>
|
|
||||||
explicit compressed_pair(const A& x) : base_type(x){}
|
|
||||||
|
|
||||||
first_reference first() { return base_type::first(); }
|
|
||||||
first_const_reference first() const { return base_type::first(); }
|
|
||||||
|
|
||||||
second_reference second() { return base_type::second(); }
|
|
||||||
second_const_reference second() const { return base_type::second(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
inline void swap(compressed_pair<T1, T2>& x, compressed_pair<T1, T2>& y)
|
|
||||||
{
|
|
||||||
x.swap(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
// no partial specialisation, no member templates:
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
class compressed_pair
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
T1 _first;
|
|
||||||
T2 _second;
|
|
||||||
public:
|
|
||||||
typedef T1 first_type;
|
|
||||||
typedef T2 second_type;
|
|
||||||
typedef typename call_traits<first_type>::param_type first_param_type;
|
|
||||||
typedef typename call_traits<second_type>::param_type second_param_type;
|
|
||||||
typedef typename call_traits<first_type>::reference first_reference;
|
|
||||||
typedef typename call_traits<second_type>::reference second_reference;
|
|
||||||
typedef typename call_traits<first_type>::const_reference first_const_reference;
|
|
||||||
typedef typename call_traits<second_type>::const_reference second_const_reference;
|
|
||||||
|
|
||||||
compressed_pair() : _first(), _second() {}
|
|
||||||
compressed_pair(first_param_type x, second_param_type y) : _first(x), _second(y) {}
|
|
||||||
explicit compressed_pair(first_param_type x) : _first(x), _second() {}
|
|
||||||
// can't define this in case T1 == T2:
|
|
||||||
// explicit compressed_pair(second_param_type y) : _first(), _second(y) {}
|
|
||||||
|
|
||||||
first_reference first() { return _first; }
|
|
||||||
first_const_reference first() const { return _first; }
|
|
||||||
|
|
||||||
second_reference second() { return _second; }
|
|
||||||
second_const_reference second() const { return _second; }
|
|
||||||
|
|
||||||
void swap(compressed_pair& y)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(_first, y._first);
|
|
||||||
swap(_second, y._second);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
|
||||||
inline void swap(compressed_pair<T1, T2>& x, compressed_pair<T1, T2>& y)
|
|
||||||
{
|
|
||||||
x.swap(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // boost
|
|
||||||
|
|
||||||
#endif // BOOST_OB_COMPRESSED_PAIR_HPP
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -1,80 +0,0 @@
|
|||||||
// (C) Copyright Jens Maurer 2001.
|
|
||||||
// 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)
|
|
||||||
//
|
|
||||||
// Revision History:
|
|
||||||
|
|
||||||
// 15 Nov 2001 Jens Maurer
|
|
||||||
// created.
|
|
||||||
|
|
||||||
// See http://www.boost.org/libs/utility/iterator_adaptors.htm for documentation.
|
|
||||||
|
|
||||||
#ifndef BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP
|
|
||||||
#define BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP
|
|
||||||
|
|
||||||
#include <boost/iterator/iterator_facade.hpp>
|
|
||||||
#include <boost/ref.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
template<class Generator>
|
|
||||||
class generator_iterator
|
|
||||||
: public iterator_facade<
|
|
||||||
generator_iterator<Generator>
|
|
||||||
, typename Generator::result_type
|
|
||||||
, single_pass_traversal_tag
|
|
||||||
, typename Generator::result_type const&
|
|
||||||
>
|
|
||||||
{
|
|
||||||
typedef iterator_facade<
|
|
||||||
generator_iterator<Generator>
|
|
||||||
, typename Generator::result_type
|
|
||||||
, single_pass_traversal_tag
|
|
||||||
, typename Generator::result_type const&
|
|
||||||
> super_t;
|
|
||||||
|
|
||||||
public:
|
|
||||||
generator_iterator() {}
|
|
||||||
generator_iterator(Generator* g) : m_g(g), m_value((*m_g)()) {}
|
|
||||||
|
|
||||||
void increment()
|
|
||||||
{
|
|
||||||
m_value = (*m_g)();
|
|
||||||
}
|
|
||||||
|
|
||||||
const typename Generator::result_type&
|
|
||||||
dereference() const
|
|
||||||
{
|
|
||||||
return m_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool equal(generator_iterator const& y) const
|
|
||||||
{
|
|
||||||
return this->m_g == y.m_g && this->m_value == y.m_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Generator* m_g;
|
|
||||||
typename Generator::result_type m_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Generator>
|
|
||||||
struct generator_iterator_generator
|
|
||||||
{
|
|
||||||
typedef generator_iterator<Generator> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class Generator>
|
|
||||||
inline generator_iterator<Generator>
|
|
||||||
make_generator_iterator(Generator & gen)
|
|
||||||
{
|
|
||||||
typedef generator_iterator<Generator> result_t;
|
|
||||||
return result_t(&gen);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP
|
|
||||||
|
|
@@ -1,51 +0,0 @@
|
|||||||
// Boost next_prior.hpp header file ---------------------------------------//
|
|
||||||
|
|
||||||
// (C) Copyright Dave Abrahams and Daniel Walker 1999-2003. 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)
|
|
||||||
|
|
||||||
// See http://www.boost.org/libs/utility for documentation.
|
|
||||||
|
|
||||||
// Revision History
|
|
||||||
// 13 Dec 2003 Added next(x, n) and prior(x, n) (Daniel Walker)
|
|
||||||
|
|
||||||
#ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED
|
|
||||||
#define BOOST_NEXT_PRIOR_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include <iterator>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
// Helper functions for classes like bidirectional iterators not supporting
|
|
||||||
// operator+ and operator-
|
|
||||||
//
|
|
||||||
// Usage:
|
|
||||||
// const std::list<T>::iterator p = get_some_iterator();
|
|
||||||
// const std::list<T>::iterator prev = boost::prior(p);
|
|
||||||
// const std::list<T>::iterator next = boost::next(prev, 2);
|
|
||||||
|
|
||||||
// Contributed by Dave Abrahams
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
inline T next(T x) { return ++x; }
|
|
||||||
|
|
||||||
template <class T, class Distance>
|
|
||||||
inline T next(T x, Distance n)
|
|
||||||
{
|
|
||||||
std::advance(x, n);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
inline T prior(T x) { return --x; }
|
|
||||||
|
|
||||||
template <class T, class Distance>
|
|
||||||
inline T prior(T x, Distance n)
|
|
||||||
{
|
|
||||||
std::advance(x, -n);
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif // BOOST_NEXT_PRIOR_HPP_INCLUDED
|
|
@@ -1,36 +0,0 @@
|
|||||||
// Boost noncopyable.hpp header file --------------------------------------//
|
|
||||||
|
|
||||||
// (C) Copyright Beman Dawes 1999-2003. 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)
|
|
||||||
|
|
||||||
// See http://www.boost.org/libs/utility for documentation.
|
|
||||||
|
|
||||||
#ifndef BOOST_NONCOPYABLE_HPP_INCLUDED
|
|
||||||
#define BOOST_NONCOPYABLE_HPP_INCLUDED
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
// Private copy constructor and copy assignment ensure classes derived from
|
|
||||||
// class noncopyable cannot be copied.
|
|
||||||
|
|
||||||
// Contributed by Dave Abrahams
|
|
||||||
|
|
||||||
namespace noncopyable_ // protection from unintended ADL
|
|
||||||
{
|
|
||||||
class noncopyable
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
noncopyable() {}
|
|
||||||
~noncopyable() {}
|
|
||||||
private: // emphasize the following members are private
|
|
||||||
noncopyable( const noncopyable& );
|
|
||||||
const noncopyable& operator=( const noncopyable& );
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef noncopyable_::noncopyable noncopyable;
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif // BOOST_NONCOPYABLE_HPP_INCLUDED
|
|
@@ -1,941 +0,0 @@
|
|||||||
// Boost operators.hpp header file ----------------------------------------//
|
|
||||||
|
|
||||||
// (C) Copyright David Abrahams, Jeremy Siek, Daryle Walker 1999-2001.
|
|
||||||
// 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)
|
|
||||||
|
|
||||||
// See http://www.boost.org/libs/utility/operators.htm for documentation.
|
|
||||||
|
|
||||||
// Revision History
|
|
||||||
// 21 Oct 02 Modified implementation of operators to allow compilers with a
|
|
||||||
// correct named return value optimization (NRVO) to produce optimal
|
|
||||||
// code. (Daniel Frey)
|
|
||||||
// 02 Dec 01 Bug fixed in random_access_iteratable. (Helmut Zeisel)
|
|
||||||
// 28 Sep 01 Factored out iterator operator groups. (Daryle Walker)
|
|
||||||
// 27 Aug 01 'left' form for non commutative operators added;
|
|
||||||
// additional classes for groups of related operators added;
|
|
||||||
// workaround for empty base class optimization
|
|
||||||
// bug of GCC 3.0 (Helmut Zeisel)
|
|
||||||
// 25 Jun 01 output_iterator_helper changes: removed default template
|
|
||||||
// parameters, added support for self-proxying, additional
|
|
||||||
// documentation and tests (Aleksey Gurtovoy)
|
|
||||||
// 29 May 01 Added operator classes for << and >>. Added input and output
|
|
||||||
// iterator helper classes. Added classes to connect equality and
|
|
||||||
// relational operators. Added classes for groups of related
|
|
||||||
// operators. Reimplemented example operator and iterator helper
|
|
||||||
// classes in terms of the new groups. (Daryle Walker, with help
|
|
||||||
// from Alexy Gurtovoy)
|
|
||||||
// 11 Feb 01 Fixed bugs in the iterator helpers which prevented explicitly
|
|
||||||
// supplied arguments from actually being used (Dave Abrahams)
|
|
||||||
// 04 Jul 00 Fixed NO_OPERATORS_IN_NAMESPACE bugs, major cleanup and
|
|
||||||
// refactoring of compiler workarounds, additional documentation
|
|
||||||
// (Alexy Gurtovoy and Mark Rodgers with some help and prompting from
|
|
||||||
// Dave Abrahams)
|
|
||||||
// 28 Jun 00 General cleanup and integration of bugfixes from Mark Rodgers and
|
|
||||||
// Jeremy Siek (Dave Abrahams)
|
|
||||||
// 20 Jun 00 Changes to accommodate Borland C++Builder 4 and Borland C++ 5.5
|
|
||||||
// (Mark Rodgers)
|
|
||||||
// 20 Jun 00 Minor fixes to the prior revision (Aleksey Gurtovoy)
|
|
||||||
// 10 Jun 00 Support for the base class chaining technique was added
|
|
||||||
// (Aleksey Gurtovoy). See documentation and the comments below
|
|
||||||
// for the details.
|
|
||||||
// 12 Dec 99 Initial version with iterator operators (Jeremy Siek)
|
|
||||||
// 18 Nov 99 Change name "divideable" to "dividable", remove unnecessary
|
|
||||||
// specializations of dividable, subtractable, modable (Ed Brey)
|
|
||||||
// 17 Nov 99 Add comments (Beman Dawes)
|
|
||||||
// Remove unnecessary specialization of operators<> (Ed Brey)
|
|
||||||
// 15 Nov 99 Fix less_than_comparable<T,U> second operand type for first two
|
|
||||||
// operators.(Beman Dawes)
|
|
||||||
// 12 Nov 99 Add operators templates (Ed Brey)
|
|
||||||
// 11 Nov 99 Add single template parameter version for compilers without
|
|
||||||
// partial specialization (Beman Dawes)
|
|
||||||
// 10 Nov 99 Initial version
|
|
||||||
|
|
||||||
// 10 Jun 00:
|
|
||||||
// An additional optional template parameter was added to most of
|
|
||||||
// operator templates to support the base class chaining technique (see
|
|
||||||
// documentation for the details). Unfortunately, a straightforward
|
|
||||||
// implementation of this change would have broken compatibility with the
|
|
||||||
// previous version of the library by making it impossible to use the same
|
|
||||||
// template name (e.g. 'addable') for both the 1- and 2-argument versions of
|
|
||||||
// an operator template. This implementation solves the backward-compatibility
|
|
||||||
// issue at the cost of some simplicity.
|
|
||||||
//
|
|
||||||
// One of the complications is an existence of special auxiliary class template
|
|
||||||
// 'is_chained_base<>' (see 'detail' namespace below), which is used
|
|
||||||
// to determine whether its template parameter is a library's operator template
|
|
||||||
// or not. You have to specialize 'is_chained_base<>' for each new
|
|
||||||
// operator template you add to the library.
|
|
||||||
//
|
|
||||||
// However, most of the non-trivial implementation details are hidden behind
|
|
||||||
// several local macros defined below, and as soon as you understand them,
|
|
||||||
// you understand the whole library implementation.
|
|
||||||
|
|
||||||
#ifndef BOOST_OPERATORS_HPP
|
|
||||||
#define BOOST_OPERATORS_HPP
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
#include <boost/detail/workaround.hpp>
|
|
||||||
|
|
||||||
#if defined(__sgi) && !defined(__GNUC__)
|
|
||||||
# pragma set woff 1234
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
# pragma warning( disable : 4284 ) // complaint about return type of
|
|
||||||
#endif // operator-> not begin a UDT
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// Helmut Zeisel, empty base class optimization bug with GCC 3.0.0
|
|
||||||
#if defined(__GNUC__) && __GNUC__==3 && __GNUC_MINOR__==0 && __GNU_PATCHLEVEL__==0
|
|
||||||
class empty_base {
|
|
||||||
bool dummy;
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
class empty_base {};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
// In this section we supply the xxxx1 and xxxx2 forms of the operator
|
|
||||||
// templates, which are explicitly targeted at the 1-type-argument and
|
|
||||||
// 2-type-argument operator forms, respectively. Some compilers get confused
|
|
||||||
// when inline friend functions are overloaded in namespaces other than the
|
|
||||||
// global namespace. When BOOST_NO_OPERATORS_IN_NAMESPACE is defined, all of
|
|
||||||
// these templates must go in the global namespace.
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Basic operator classes (contributed by Dave Abrahams) ------------------//
|
|
||||||
|
|
||||||
// Note that friend functions defined in a class are implicitly inline.
|
|
||||||
// See the C++ std, 11.4 [class.friend] paragraph 5
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct less_than_comparable2 : B
|
|
||||||
{
|
|
||||||
friend bool operator<=(const T& x, const U& y) { return !(x > y); }
|
|
||||||
friend bool operator>=(const T& x, const U& y) { return !(x < y); }
|
|
||||||
friend bool operator>(const U& x, const T& y) { return y < x; }
|
|
||||||
friend bool operator<(const U& x, const T& y) { return y > x; }
|
|
||||||
friend bool operator<=(const U& x, const T& y) { return !(y < x); }
|
|
||||||
friend bool operator>=(const U& x, const T& y) { return !(y > x); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct less_than_comparable1 : B
|
|
||||||
{
|
|
||||||
friend bool operator>(const T& x, const T& y) { return y < x; }
|
|
||||||
friend bool operator<=(const T& x, const T& y) { return !(y < x); }
|
|
||||||
friend bool operator>=(const T& x, const T& y) { return !(x < y); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct equality_comparable2 : B
|
|
||||||
{
|
|
||||||
friend bool operator==(const U& y, const T& x) { return x == y; }
|
|
||||||
friend bool operator!=(const U& y, const T& x) { return !(x == y); }
|
|
||||||
friend bool operator!=(const T& y, const U& x) { return !(y == x); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct equality_comparable1 : B
|
|
||||||
{
|
|
||||||
friend bool operator!=(const T& x, const T& y) { return !(x == y); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// A macro which produces "name_2left" from "name".
|
|
||||||
#define BOOST_OPERATOR2_LEFT(name) name##2##_##left
|
|
||||||
|
|
||||||
// NRVO-friendly implementation (contributed by Daniel Frey) ---------------//
|
|
||||||
|
|
||||||
#if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
|
||||||
|
|
||||||
// This is the optimal implementation for ISO/ANSI C++,
|
|
||||||
// but it requires the compiler to implement the NRVO.
|
|
||||||
// If the compiler has no NRVO, this is the best symmetric
|
|
||||||
// implementation available.
|
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##2 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
|
||||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
|
||||||
{ T nrv( rhs ); nrv OP##= lhs; return nrv; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##1 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
|
||||||
};
|
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##2 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
|
||||||
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##1 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
|
||||||
};
|
|
||||||
|
|
||||||
#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
|
||||||
|
|
||||||
// For compilers without NRVO the following code is optimal, but not
|
|
||||||
// symmetric! Note that the implementation of
|
|
||||||
// BOOST_OPERATOR2_LEFT(NAME) only looks cool, but doesn't provide
|
|
||||||
// optimization opportunities to the compiler :)
|
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##2 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
|
||||||
friend T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##1 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
|
||||||
};
|
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##2 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
|
||||||
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
|
||||||
{ return T( lhs ) OP##= rhs; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##1 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
|
||||||
|
|
||||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( multipliable, * )
|
|
||||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( addable, + )
|
|
||||||
BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( subtractable, - )
|
|
||||||
BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( dividable, / )
|
|
||||||
BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( modable, % )
|
|
||||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( xorable, ^ )
|
|
||||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( andable, & )
|
|
||||||
BOOST_BINARY_OPERATOR_COMMUTATIVE( orable, | )
|
|
||||||
|
|
||||||
#undef BOOST_BINARY_OPERATOR_COMMUTATIVE
|
|
||||||
#undef BOOST_BINARY_OPERATOR_NON_COMMUTATIVE
|
|
||||||
#undef BOOST_OPERATOR2_LEFT
|
|
||||||
|
|
||||||
// incrementable and decrementable contributed by Jeremy Siek
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct incrementable : B
|
|
||||||
{
|
|
||||||
friend T operator++(T& x, int)
|
|
||||||
{
|
|
||||||
incrementable_type nrv(x);
|
|
||||||
++x;
|
|
||||||
return nrv;
|
|
||||||
}
|
|
||||||
private: // The use of this typedef works around a Borland bug
|
|
||||||
typedef T incrementable_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct decrementable : B
|
|
||||||
{
|
|
||||||
friend T operator--(T& x, int)
|
|
||||||
{
|
|
||||||
decrementable_type nrv(x);
|
|
||||||
--x;
|
|
||||||
return nrv;
|
|
||||||
}
|
|
||||||
private: // The use of this typedef works around a Borland bug
|
|
||||||
typedef T decrementable_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Iterator operator classes (contributed by Jeremy Siek) ------------------//
|
|
||||||
|
|
||||||
template <class T, class P, class B = ::boost::detail::empty_base>
|
|
||||||
struct dereferenceable : B
|
|
||||||
{
|
|
||||||
P operator->() const
|
|
||||||
{
|
|
||||||
return &*static_cast<const T&>(*this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class I, class R, class B = ::boost::detail::empty_base>
|
|
||||||
struct indexable : B
|
|
||||||
{
|
|
||||||
R operator[](I n) const
|
|
||||||
{
|
|
||||||
return *(static_cast<const T&>(*this) + n);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// More operator classes (contributed by Daryle Walker) --------------------//
|
|
||||||
// (NRVO-friendly implementation contributed by Daniel Frey) ---------------//
|
|
||||||
|
|
||||||
#if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##2 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##1 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
|
||||||
};
|
|
||||||
|
|
||||||
#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##2 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
|
||||||
struct NAME##1 : B \
|
|
||||||
{ \
|
|
||||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
|
||||||
|
|
||||||
BOOST_BINARY_OPERATOR( left_shiftable, << )
|
|
||||||
BOOST_BINARY_OPERATOR( right_shiftable, >> )
|
|
||||||
|
|
||||||
#undef BOOST_BINARY_OPERATOR
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct equivalent2 : B
|
|
||||||
{
|
|
||||||
friend bool operator==(const T& x, const U& y)
|
|
||||||
{
|
|
||||||
return !(x < y) && !(x > y);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct equivalent1 : B
|
|
||||||
{
|
|
||||||
friend bool operator==(const T&x, const T&y)
|
|
||||||
{
|
|
||||||
return !(x < y) && !(y < x);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct partially_ordered2 : B
|
|
||||||
{
|
|
||||||
friend bool operator<=(const T& x, const U& y)
|
|
||||||
{ return (x < y) || (x == y); }
|
|
||||||
friend bool operator>=(const T& x, const U& y)
|
|
||||||
{ return (x > y) || (x == y); }
|
|
||||||
friend bool operator>(const U& x, const T& y)
|
|
||||||
{ return y < x; }
|
|
||||||
friend bool operator<(const U& x, const T& y)
|
|
||||||
{ return y > x; }
|
|
||||||
friend bool operator<=(const U& x, const T& y)
|
|
||||||
{ return (y > x) || (y == x); }
|
|
||||||
friend bool operator>=(const U& x, const T& y)
|
|
||||||
{ return (y < x) || (y == x); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct partially_ordered1 : B
|
|
||||||
{
|
|
||||||
friend bool operator>(const T& x, const T& y)
|
|
||||||
{ return y < x; }
|
|
||||||
friend bool operator<=(const T& x, const T& y)
|
|
||||||
{ return (x < y) || (x == y); }
|
|
||||||
friend bool operator>=(const T& x, const T& y)
|
|
||||||
{ return (y < x) || (x == y); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Combined operator classes (contributed by Daryle Walker) ----------------//
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct totally_ordered2
|
|
||||||
: less_than_comparable2<T, U
|
|
||||||
, equality_comparable2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct totally_ordered1
|
|
||||||
: less_than_comparable1<T
|
|
||||||
, equality_comparable1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct additive2
|
|
||||||
: addable2<T, U
|
|
||||||
, subtractable2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct additive1
|
|
||||||
: addable1<T
|
|
||||||
, subtractable1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct multiplicative2
|
|
||||||
: multipliable2<T, U
|
|
||||||
, dividable2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct multiplicative1
|
|
||||||
: multipliable1<T
|
|
||||||
, dividable1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct integer_multiplicative2
|
|
||||||
: multiplicative2<T, U
|
|
||||||
, modable2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct integer_multiplicative1
|
|
||||||
: multiplicative1<T
|
|
||||||
, modable1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct arithmetic2
|
|
||||||
: additive2<T, U
|
|
||||||
, multiplicative2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct arithmetic1
|
|
||||||
: additive1<T
|
|
||||||
, multiplicative1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct integer_arithmetic2
|
|
||||||
: additive2<T, U
|
|
||||||
, integer_multiplicative2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct integer_arithmetic1
|
|
||||||
: additive1<T
|
|
||||||
, integer_multiplicative1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct bitwise2
|
|
||||||
: xorable2<T, U
|
|
||||||
, andable2<T, U
|
|
||||||
, orable2<T, U, B
|
|
||||||
> > > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct bitwise1
|
|
||||||
: xorable1<T
|
|
||||||
, andable1<T
|
|
||||||
, orable1<T, B
|
|
||||||
> > > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct unit_steppable
|
|
||||||
: incrementable<T
|
|
||||||
, decrementable<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct shiftable2
|
|
||||||
: left_shiftable2<T, U
|
|
||||||
, right_shiftable2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct shiftable1
|
|
||||||
: left_shiftable1<T
|
|
||||||
, right_shiftable1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct ring_operators2
|
|
||||||
: additive2<T, U
|
|
||||||
, subtractable2_left<T, U
|
|
||||||
, multipliable2<T, U, B
|
|
||||||
> > > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct ring_operators1
|
|
||||||
: additive1<T
|
|
||||||
, multipliable1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct ordered_ring_operators2
|
|
||||||
: ring_operators2<T, U
|
|
||||||
, totally_ordered2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct ordered_ring_operators1
|
|
||||||
: ring_operators1<T
|
|
||||||
, totally_ordered1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct field_operators2
|
|
||||||
: ring_operators2<T, U
|
|
||||||
, dividable2<T, U
|
|
||||||
, dividable2_left<T, U, B
|
|
||||||
> > > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct field_operators1
|
|
||||||
: ring_operators1<T
|
|
||||||
, dividable1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct ordered_field_operators2
|
|
||||||
: field_operators2<T, U
|
|
||||||
, totally_ordered2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct ordered_field_operators1
|
|
||||||
: field_operators1<T
|
|
||||||
, totally_ordered1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct euclidian_ring_operators2
|
|
||||||
: ring_operators2<T, U
|
|
||||||
, dividable2<T, U
|
|
||||||
, dividable2_left<T, U
|
|
||||||
, modable2<T, U
|
|
||||||
, modable2_left<T, U, B
|
|
||||||
> > > > > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct euclidian_ring_operators1
|
|
||||||
: ring_operators1<T
|
|
||||||
, dividable1<T
|
|
||||||
, modable1<T, B
|
|
||||||
> > > {};
|
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
|
||||||
struct ordered_euclidian_ring_operators2
|
|
||||||
: totally_ordered2<T, U
|
|
||||||
, euclidian_ring_operators2<T, U, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct ordered_euclidian_ring_operators1
|
|
||||||
: totally_ordered1<T
|
|
||||||
, euclidian_ring_operators1<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T, class P, class B = ::boost::detail::empty_base>
|
|
||||||
struct input_iteratable
|
|
||||||
: equality_comparable1<T
|
|
||||||
, incrementable<T
|
|
||||||
, dereferenceable<T, P, B
|
|
||||||
> > > {};
|
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
|
||||||
struct output_iteratable
|
|
||||||
: incrementable<T, B
|
|
||||||
> {};
|
|
||||||
|
|
||||||
template <class T, class P, class B = ::boost::detail::empty_base>
|
|
||||||
struct forward_iteratable
|
|
||||||
: input_iteratable<T, P, B
|
|
||||||
> {};
|
|
||||||
|
|
||||||
template <class T, class P, class B = ::boost::detail::empty_base>
|
|
||||||
struct bidirectional_iteratable
|
|
||||||
: forward_iteratable<T, P
|
|
||||||
, decrementable<T, B
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
// To avoid repeated derivation from equality_comparable,
|
|
||||||
// which is an indirect base class of bidirectional_iterable,
|
|
||||||
// random_access_iteratable must not be derived from totally_ordered1
|
|
||||||
// but from less_than_comparable1 only. (Helmut Zeisel, 02-Dec-2001)
|
|
||||||
template <class T, class P, class D, class R, class B = ::boost::detail::empty_base>
|
|
||||||
struct random_access_iteratable
|
|
||||||
: bidirectional_iteratable<T, P
|
|
||||||
, less_than_comparable1<T
|
|
||||||
, additive2<T, D
|
|
||||||
, indexable<T, D, R, B
|
|
||||||
> > > > {};
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
|
||||||
} // namespace boost
|
|
||||||
#endif // BOOST_NO_OPERATORS_IN_NAMESPACE
|
|
||||||
|
|
||||||
|
|
||||||
// BOOST_IMPORT_TEMPLATE1 .. BOOST_IMPORT_TEMPLATE4 -
|
|
||||||
//
|
|
||||||
// When BOOST_NO_OPERATORS_IN_NAMESPACE is defined we need a way to import an
|
|
||||||
// operator template into the boost namespace. BOOST_IMPORT_TEMPLATE1 is used
|
|
||||||
// for one-argument forms of operator templates; BOOST_IMPORT_TEMPLATE2 for
|
|
||||||
// two-argument forms. Note that these macros expect to be invoked from within
|
|
||||||
// boost.
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
|
|
||||||
|
|
||||||
// The template is already in boost so we have nothing to do.
|
|
||||||
# define BOOST_IMPORT_TEMPLATE4(template_name)
|
|
||||||
# define BOOST_IMPORT_TEMPLATE3(template_name)
|
|
||||||
# define BOOST_IMPORT_TEMPLATE2(template_name)
|
|
||||||
# define BOOST_IMPORT_TEMPLATE1(template_name)
|
|
||||||
|
|
||||||
#else // BOOST_NO_OPERATORS_IN_NAMESPACE
|
|
||||||
|
|
||||||
# ifndef BOOST_NO_USING_TEMPLATE
|
|
||||||
|
|
||||||
// Bring the names in with a using-declaration
|
|
||||||
// to avoid stressing the compiler.
|
|
||||||
# define BOOST_IMPORT_TEMPLATE4(template_name) using ::template_name;
|
|
||||||
# define BOOST_IMPORT_TEMPLATE3(template_name) using ::template_name;
|
|
||||||
# define BOOST_IMPORT_TEMPLATE2(template_name) using ::template_name;
|
|
||||||
# define BOOST_IMPORT_TEMPLATE1(template_name) using ::template_name;
|
|
||||||
|
|
||||||
# else
|
|
||||||
|
|
||||||
// Otherwise, because a Borland C++ 5.5 bug prevents a using declaration
|
|
||||||
// from working, we are forced to use inheritance for that compiler.
|
|
||||||
# define BOOST_IMPORT_TEMPLATE4(template_name) \
|
|
||||||
template <class T, class U, class V, class W, class B = ::boost::detail::empty_base> \
|
|
||||||
struct template_name : ::template_name<T, U, V, W, B> {};
|
|
||||||
|
|
||||||
# define BOOST_IMPORT_TEMPLATE3(template_name) \
|
|
||||||
template <class T, class U, class V, class B = ::boost::detail::empty_base> \
|
|
||||||
struct template_name : ::template_name<T, U, V, B> {};
|
|
||||||
|
|
||||||
# define BOOST_IMPORT_TEMPLATE2(template_name) \
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
|
||||||
struct template_name : ::template_name<T, U, B> {};
|
|
||||||
|
|
||||||
# define BOOST_IMPORT_TEMPLATE1(template_name) \
|
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
|
||||||
struct template_name : ::template_name<T, B> {};
|
|
||||||
|
|
||||||
# endif // BOOST_NO_USING_TEMPLATE
|
|
||||||
|
|
||||||
#endif // BOOST_NO_OPERATORS_IN_NAMESPACE
|
|
||||||
|
|
||||||
//
|
|
||||||
// Here's where we put it all together, defining the xxxx forms of the templates
|
|
||||||
// in namespace boost. We also define specializations of is_chained_base<> for
|
|
||||||
// the xxxx, xxxx1, and xxxx2 templates, importing them into boost:: as
|
|
||||||
// necessary.
|
|
||||||
//
|
|
||||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
|
|
||||||
// is_chained_base<> - a traits class used to distinguish whether an operator
|
|
||||||
// template argument is being used for base class chaining, or is specifying a
|
|
||||||
// 2nd argument type.
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
// A type parameter is used instead of a plain bool because Borland's compiler
|
|
||||||
// didn't cope well with the more obvious non-type template parameter.
|
|
||||||
namespace detail {
|
|
||||||
struct true_t {};
|
|
||||||
struct false_t {};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
// Unspecialized version assumes that most types are not being used for base
|
|
||||||
// class chaining. We specialize for the operator templates defined in this
|
|
||||||
// library.
|
|
||||||
template<class T> struct is_chained_base {
|
|
||||||
typedef ::boost::detail::false_t value;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
// Import a 4-type-argument operator template into boost (if necessary) and
|
|
||||||
// provide a specialization of 'is_chained_base<>' for it.
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE4(template_name4) \
|
|
||||||
BOOST_IMPORT_TEMPLATE4(template_name4) \
|
|
||||||
template<class T, class U, class V, class W, class B> \
|
|
||||||
struct is_chained_base< ::boost::template_name4<T, U, V, W, B> > { \
|
|
||||||
typedef ::boost::detail::true_t value; \
|
|
||||||
};
|
|
||||||
|
|
||||||
// Import a 3-type-argument operator template into boost (if necessary) and
|
|
||||||
// provide a specialization of 'is_chained_base<>' for it.
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE3(template_name3) \
|
|
||||||
BOOST_IMPORT_TEMPLATE3(template_name3) \
|
|
||||||
template<class T, class U, class V, class B> \
|
|
||||||
struct is_chained_base< ::boost::template_name3<T, U, V, B> > { \
|
|
||||||
typedef ::boost::detail::true_t value; \
|
|
||||||
};
|
|
||||||
|
|
||||||
// Import a 2-type-argument operator template into boost (if necessary) and
|
|
||||||
// provide a specialization of 'is_chained_base<>' for it.
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE2(template_name2) \
|
|
||||||
BOOST_IMPORT_TEMPLATE2(template_name2) \
|
|
||||||
template<class T, class U, class B> \
|
|
||||||
struct is_chained_base< ::boost::template_name2<T, U, B> > { \
|
|
||||||
typedef ::boost::detail::true_t value; \
|
|
||||||
};
|
|
||||||
|
|
||||||
// Import a 1-type-argument operator template into boost (if necessary) and
|
|
||||||
// provide a specialization of 'is_chained_base<>' for it.
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE1(template_name1) \
|
|
||||||
BOOST_IMPORT_TEMPLATE1(template_name1) \
|
|
||||||
template<class T, class B> \
|
|
||||||
struct is_chained_base< ::boost::template_name1<T, B> > { \
|
|
||||||
typedef ::boost::detail::true_t value; \
|
|
||||||
};
|
|
||||||
|
|
||||||
// BOOST_OPERATOR_TEMPLATE(template_name) defines template_name<> such that it
|
|
||||||
// can be used for specifying both 1-argument and 2-argument forms. Requires the
|
|
||||||
// existence of two previously defined class templates named '<template_name>1'
|
|
||||||
// and '<template_name>2' which must implement the corresponding 1- and 2-
|
|
||||||
// argument forms.
|
|
||||||
//
|
|
||||||
// The template type parameter O == is_chained_base<U>::value is used to
|
|
||||||
// distinguish whether the 2nd argument to <template_name> is being used for
|
|
||||||
// base class chaining from another boost operator template or is describing a
|
|
||||||
// 2nd operand type. O == true_t only when U is actually an another operator
|
|
||||||
// template from the library. Partial specialization is used to select an
|
|
||||||
// implementation in terms of either '<template_name>1' or '<template_name>2'.
|
|
||||||
//
|
|
||||||
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE(template_name) \
|
|
||||||
template <class T \
|
|
||||||
,class U = T \
|
|
||||||
,class B = ::boost::detail::empty_base \
|
|
||||||
,class O = typename is_chained_base<U>::value \
|
|
||||||
> \
|
|
||||||
struct template_name : template_name##2<T, U, B> {}; \
|
|
||||||
\
|
|
||||||
template<class T, class U, class B> \
|
|
||||||
struct template_name<T, U, B, ::boost::detail::true_t> \
|
|
||||||
: template_name##1<T, U> {}; \
|
|
||||||
\
|
|
||||||
template <class T, class B> \
|
|
||||||
struct template_name<T, T, B, ::boost::detail::false_t> \
|
|
||||||
: template_name##1<T, B> {}; \
|
|
||||||
\
|
|
||||||
template<class T, class U, class B, class O> \
|
|
||||||
struct is_chained_base< ::boost::template_name<T, U, B, O> > { \
|
|
||||||
typedef ::boost::detail::true_t value; \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
BOOST_OPERATOR_TEMPLATE2(template_name##2) \
|
|
||||||
BOOST_OPERATOR_TEMPLATE1(template_name##1)
|
|
||||||
|
|
||||||
|
|
||||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE4(template_name4) \
|
|
||||||
BOOST_IMPORT_TEMPLATE4(template_name4)
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE3(template_name3) \
|
|
||||||
BOOST_IMPORT_TEMPLATE3(template_name3)
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE2(template_name2) \
|
|
||||||
BOOST_IMPORT_TEMPLATE2(template_name2)
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE1(template_name1) \
|
|
||||||
BOOST_IMPORT_TEMPLATE1(template_name1)
|
|
||||||
|
|
||||||
// In this case we can only assume that template_name<> is equivalent to the
|
|
||||||
// more commonly needed template_name1<> form.
|
|
||||||
# define BOOST_OPERATOR_TEMPLATE(template_name) \
|
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
|
||||||
struct template_name : template_name##1<T, B> {};
|
|
||||||
|
|
||||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
BOOST_OPERATOR_TEMPLATE(less_than_comparable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(equality_comparable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(multipliable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(addable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(subtractable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE2(subtractable2_left)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(dividable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE2(dividable2_left)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(modable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE2(modable2_left)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(xorable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(andable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(orable)
|
|
||||||
|
|
||||||
BOOST_OPERATOR_TEMPLATE1(incrementable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE1(decrementable)
|
|
||||||
|
|
||||||
BOOST_OPERATOR_TEMPLATE2(dereferenceable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE3(indexable)
|
|
||||||
|
|
||||||
BOOST_OPERATOR_TEMPLATE(left_shiftable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(right_shiftable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(equivalent)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(partially_ordered)
|
|
||||||
|
|
||||||
BOOST_OPERATOR_TEMPLATE(totally_ordered)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(additive)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(multiplicative)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(integer_multiplicative)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(arithmetic)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(integer_arithmetic)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(bitwise)
|
|
||||||
BOOST_OPERATOR_TEMPLATE1(unit_steppable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(shiftable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(ring_operators)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(ordered_ring_operators)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(field_operators)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(ordered_field_operators)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(euclidian_ring_operators)
|
|
||||||
BOOST_OPERATOR_TEMPLATE(ordered_euclidian_ring_operators)
|
|
||||||
BOOST_OPERATOR_TEMPLATE2(input_iteratable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE1(output_iteratable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE2(forward_iteratable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE2(bidirectional_iteratable)
|
|
||||||
BOOST_OPERATOR_TEMPLATE4(random_access_iteratable)
|
|
||||||
|
|
||||||
#undef BOOST_OPERATOR_TEMPLATE
|
|
||||||
#undef BOOST_OPERATOR_TEMPLATE4
|
|
||||||
#undef BOOST_OPERATOR_TEMPLATE3
|
|
||||||
#undef BOOST_OPERATOR_TEMPLATE2
|
|
||||||
#undef BOOST_OPERATOR_TEMPLATE1
|
|
||||||
#undef BOOST_IMPORT_TEMPLATE1
|
|
||||||
#undef BOOST_IMPORT_TEMPLATE2
|
|
||||||
#undef BOOST_IMPORT_TEMPLATE3
|
|
||||||
#undef BOOST_IMPORT_TEMPLATE4
|
|
||||||
|
|
||||||
// The following 'operators' classes can only be used portably if the derived class
|
|
||||||
// declares ALL of the required member operators.
|
|
||||||
template <class T, class U>
|
|
||||||
struct operators2
|
|
||||||
: totally_ordered2<T,U
|
|
||||||
, integer_arithmetic2<T,U
|
|
||||||
, bitwise2<T,U
|
|
||||||
> > > {};
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
template <class T, class U = T>
|
|
||||||
struct operators : operators2<T, U> {};
|
|
||||||
|
|
||||||
template <class T> struct operators<T, T>
|
|
||||||
#else
|
|
||||||
template <class T> struct operators
|
|
||||||
#endif
|
|
||||||
: totally_ordered<T
|
|
||||||
, integer_arithmetic<T
|
|
||||||
, bitwise<T
|
|
||||||
, unit_steppable<T
|
|
||||||
> > > > {};
|
|
||||||
|
|
||||||
// Iterator helper classes (contributed by Jeremy Siek) -------------------//
|
|
||||||
// (Input and output iterator helpers contributed by Daryle Walker) -------//
|
|
||||||
// (Changed to use combined operator classes by Daryle Walker) ------------//
|
|
||||||
template <class T,
|
|
||||||
class V,
|
|
||||||
class D = std::ptrdiff_t,
|
|
||||||
class P = V const *,
|
|
||||||
class R = V const &>
|
|
||||||
struct input_iterator_helper
|
|
||||||
: input_iteratable<T, P
|
|
||||||
, boost::iterator<std::input_iterator_tag, V, D, P, R
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct output_iterator_helper
|
|
||||||
: output_iteratable<T
|
|
||||||
, boost::iterator<std::output_iterator_tag, void, void, void, void
|
|
||||||
> >
|
|
||||||
{
|
|
||||||
T& operator*() { return static_cast<T&>(*this); }
|
|
||||||
T& operator++() { return static_cast<T&>(*this); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T,
|
|
||||||
class V,
|
|
||||||
class D = std::ptrdiff_t,
|
|
||||||
class P = V*,
|
|
||||||
class R = V&>
|
|
||||||
struct forward_iterator_helper
|
|
||||||
: forward_iteratable<T, P
|
|
||||||
, boost::iterator<std::forward_iterator_tag, V, D, P, R
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T,
|
|
||||||
class V,
|
|
||||||
class D = std::ptrdiff_t,
|
|
||||||
class P = V*,
|
|
||||||
class R = V&>
|
|
||||||
struct bidirectional_iterator_helper
|
|
||||||
: bidirectional_iteratable<T, P
|
|
||||||
, boost::iterator<std::bidirectional_iterator_tag, V, D, P, R
|
|
||||||
> > {};
|
|
||||||
|
|
||||||
template <class T,
|
|
||||||
class V,
|
|
||||||
class D = std::ptrdiff_t,
|
|
||||||
class P = V*,
|
|
||||||
class R = V&>
|
|
||||||
struct random_access_iterator_helper
|
|
||||||
: random_access_iteratable<T, P, D, R
|
|
||||||
, boost::iterator<std::random_access_iterator_tag, V, D, P, R
|
|
||||||
> >
|
|
||||||
{
|
|
||||||
friend D requires_difference_operator(const T& x, const T& y) {
|
|
||||||
return x - y;
|
|
||||||
}
|
|
||||||
}; // random_access_iterator_helper
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#if defined(__sgi) && !defined(__GNUC__)
|
|
||||||
#pragma reset woff 1234
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // BOOST_OPERATORS_HPP
|
|
@@ -1,177 +0,0 @@
|
|||||||
#ifndef BOOST_REF_HPP_INCLUDED
|
|
||||||
#define BOOST_REF_HPP_INCLUDED
|
|
||||||
|
|
||||||
// MS compatible compilers support #pragma once
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <boost/utility/addressof.hpp>
|
|
||||||
#include <boost/mpl/bool.hpp>
|
|
||||||
|
|
||||||
//
|
|
||||||
// ref.hpp - ref/cref, useful helper functions
|
|
||||||
//
|
|
||||||
// Copyright (C) 1999, 2000 Jaakko J<>rvi (jaakko.jarvi@cs.utu.fi)
|
|
||||||
// Copyright (C) 2001, 2002 Peter Dimov
|
|
||||||
// Copyright (C) 2002 David Abrahams
|
|
||||||
//
|
|
||||||
// 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)
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/libs/bind/ref.html for documentation.
|
|
||||||
//
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
template<class T> class reference_wrapper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T type;
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
|
||||||
|
|
||||||
explicit reference_wrapper(T& t): t_(&t) {}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
explicit reference_wrapper(T& t): t_(boost::addressof(t)) {}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
operator T& () const { return *t_; }
|
|
||||||
|
|
||||||
T& get() const { return *t_; }
|
|
||||||
|
|
||||||
T* get_pointer() const { return t_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
T* t_;
|
|
||||||
};
|
|
||||||
|
|
||||||
# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x570)
|
|
||||||
# define BOOST_REF_CONST
|
|
||||||
# else
|
|
||||||
# define BOOST_REF_CONST const
|
|
||||||
# endif
|
|
||||||
|
|
||||||
template<class T> inline reference_wrapper<T> BOOST_REF_CONST ref(T & t)
|
|
||||||
{
|
|
||||||
return reference_wrapper<T>(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T> inline reference_wrapper<T const> BOOST_REF_CONST cref(T const & t)
|
|
||||||
{
|
|
||||||
return reference_wrapper<T const>(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
# undef BOOST_REF_CONST
|
|
||||||
|
|
||||||
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class is_reference_wrapper
|
|
||||||
: public mpl::false_
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class unwrap_reference
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
|
|
||||||
# define AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(X) \
|
|
||||||
template<typename T> \
|
|
||||||
class is_reference_wrapper< X > \
|
|
||||||
: public mpl::true_ \
|
|
||||||
{ \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
template<typename T> \
|
|
||||||
class unwrap_reference< X > \
|
|
||||||
{ \
|
|
||||||
public: \
|
|
||||||
typedef T type; \
|
|
||||||
}; \
|
|
||||||
/**/
|
|
||||||
|
|
||||||
AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T>)
|
|
||||||
#if !defined(BOOST_NO_CV_SPECIALIZATIONS)
|
|
||||||
AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T> const)
|
|
||||||
AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T> volatile)
|
|
||||||
AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T> const volatile)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# undef AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF
|
|
||||||
|
|
||||||
# else // no partial specialization
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#include <boost/type.hpp>
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
typedef char (&yes_reference_wrapper_t)[1];
|
|
||||||
typedef char (&no_reference_wrapper_t)[2];
|
|
||||||
|
|
||||||
no_reference_wrapper_t is_reference_wrapper_test(...);
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
yes_reference_wrapper_t is_reference_wrapper_test(type< reference_wrapper<T> >);
|
|
||||||
|
|
||||||
template<bool wrapped>
|
|
||||||
struct reference_unwrapper
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct apply
|
|
||||||
{
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct reference_unwrapper<true>
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct apply
|
|
||||||
{
|
|
||||||
typedef typename T::type type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class is_reference_wrapper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BOOST_STATIC_CONSTANT(
|
|
||||||
bool, value = (
|
|
||||||
sizeof(detail::is_reference_wrapper_test(type<T>()))
|
|
||||||
== sizeof(detail::yes_reference_wrapper_t)));
|
|
||||||
|
|
||||||
typedef ::boost::mpl::bool_<value> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class unwrap_reference
|
|
||||||
: public detail::reference_unwrapper<
|
|
||||||
is_reference_wrapper<T>::value
|
|
||||||
>::template apply<T>
|
|
||||||
{};
|
|
||||||
|
|
||||||
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif // #ifndef BOOST_REF_HPP_INCLUDED
|
|
@@ -1,19 +0,0 @@
|
|||||||
// Boost utility.hpp header file -------------------------------------------//
|
|
||||||
|
|
||||||
// Copyright 1999-2003 Aleksey Gurtovoy. Use, modification, and distribution are
|
|
||||||
// subject to the Boost Software License, Version 1.0. (See accompanying file
|
|
||||||
// LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
|
||||||
|
|
||||||
// See <http://www.boost.org/libs/utility/> for the library's home page.
|
|
||||||
|
|
||||||
#ifndef BOOST_UTILITY_HPP
|
|
||||||
#define BOOST_UTILITY_HPP
|
|
||||||
|
|
||||||
#include <boost/utility/addressof.hpp>
|
|
||||||
#include <boost/utility/base_from_member.hpp>
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
#include <boost/checked_delete.hpp>
|
|
||||||
#include <boost/next_prior.hpp>
|
|
||||||
#include <boost/noncopyable.hpp>
|
|
||||||
|
|
||||||
#endif // BOOST_UTILITY_HPP
|
|
@@ -1,58 +0,0 @@
|
|||||||
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
|
|
||||||
// Douglas Gregor (gregod@cs.rpi.edu)
|
|
||||||
// Peter Dimov
|
|
||||||
//
|
|
||||||
// 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)
|
|
||||||
|
|
||||||
// For more information, see http://www.boost.org
|
|
||||||
|
|
||||||
#ifndef BOOST_UTILITY_ADDRESSOF_HPP
|
|
||||||
# define BOOST_UTILITY_ADDRESSOF_HPP
|
|
||||||
|
|
||||||
# include <boost/config.hpp>
|
|
||||||
# include <boost/detail/workaround.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
|
|
||||||
|
|
||||||
// VC7 strips const from nested classes unless we add indirection here
|
|
||||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
|
||||||
|
|
||||||
template<class T> struct _addp
|
|
||||||
{
|
|
||||||
typedef T * type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T> typename _addp<T>::type
|
|
||||||
|
|
||||||
# else
|
|
||||||
template <typename T> T*
|
|
||||||
# endif
|
|
||||||
addressof(T& v)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<T*>(
|
|
||||||
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Borland doesn't like casting an array reference to a char reference
|
|
||||||
// but these overloads work around the problem.
|
|
||||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
|
||||||
template<typename T,std::size_t N>
|
|
||||||
T (*addressof(T (&t)[N]))[N]
|
|
||||||
{
|
|
||||||
return reinterpret_cast<T(*)[N]>(&t);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T,std::size_t N>
|
|
||||||
const T (*addressof(const T (&t)[N]))[N]
|
|
||||||
{
|
|
||||||
return reinterpret_cast<const T(*)[N]>(&t);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BOOST_UTILITY_ADDRESSOF_HPP
|
|
@@ -1,87 +0,0 @@
|
|||||||
// boost utility/base_from_member.hpp header file --------------------------//
|
|
||||||
|
|
||||||
// Copyright 2001, 2003, 2004 Daryle Walker. Use, modification, and
|
|
||||||
// distribution are subject to the Boost Software License, Version 1.0. (See
|
|
||||||
// accompanying file LICENSE_1_0.txt or a copy at
|
|
||||||
// <http://www.boost.org/LICENSE_1_0.txt>.)
|
|
||||||
|
|
||||||
// See <http://www.boost.org/libs/utility/> for the library's home page.
|
|
||||||
|
|
||||||
#ifndef BOOST_UTILITY_BASE_FROM_MEMBER_HPP
|
|
||||||
#define BOOST_UTILITY_BASE_FROM_MEMBER_HPP
|
|
||||||
|
|
||||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
|
||||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
|
||||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
|
||||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
// Base-from-member arity configuration macro ------------------------------//
|
|
||||||
|
|
||||||
// The following macro determines how many arguments will be in the largest
|
|
||||||
// constructor template of base_from_member. Constructor templates will be
|
|
||||||
// generated from one argument to this maximum. Code from other files can read
|
|
||||||
// this number if they need to always match the exact maximum base_from_member
|
|
||||||
// uses. The maximum constructor length can be changed by overriding the
|
|
||||||
// #defined constant. Make sure to apply the override, if any, for all source
|
|
||||||
// files during project compiling for consistency.
|
|
||||||
|
|
||||||
// Contributed by Jonathan Turkanis
|
|
||||||
|
|
||||||
#ifndef BOOST_BASE_FROM_MEMBER_MAX_ARITY
|
|
||||||
#define BOOST_BASE_FROM_MEMBER_MAX_ARITY 10
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// An iteration of a constructor template for base_from_member -------------//
|
|
||||||
|
|
||||||
// A macro that should expand to:
|
|
||||||
// template < typename T1, ..., typename Tn >
|
|
||||||
// base_from_member( T1 x1, ..., Tn xn )
|
|
||||||
// : member( x1, ..., xn )
|
|
||||||
// {}
|
|
||||||
// This macro should only persist within this file.
|
|
||||||
|
|
||||||
#define BOOST_PRIVATE_CTR_DEF( z, n, data ) \
|
|
||||||
template < BOOST_PP_ENUM_PARAMS(n, typename T) > \
|
|
||||||
explicit base_from_member( BOOST_PP_ENUM_BINARY_PARAMS(n, T, x) ) \
|
|
||||||
: member( BOOST_PP_ENUM_PARAMS(n, x) ) \
|
|
||||||
{} \
|
|
||||||
/**/
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
// Base-from-member class template -----------------------------------------//
|
|
||||||
|
|
||||||
// Helper to initialize a base object so a derived class can use this
|
|
||||||
// object in the initialization of another base class. Used by
|
|
||||||
// Dietmar Kuehl from ideas by Ron Klatcho to solve the problem of a
|
|
||||||
// base class needing to be initialized by a member.
|
|
||||||
|
|
||||||
// Contributed by Daryle Walker
|
|
||||||
|
|
||||||
template < typename MemberType, int UniqueID = 0 >
|
|
||||||
class base_from_member
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
MemberType member;
|
|
||||||
|
|
||||||
base_from_member()
|
|
||||||
: member()
|
|
||||||
{}
|
|
||||||
|
|
||||||
BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_INC(BOOST_BASE_FROM_MEMBER_MAX_ARITY),
|
|
||||||
BOOST_PRIVATE_CTR_DEF, _ )
|
|
||||||
|
|
||||||
}; // boost::base_from_member
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
|
|
||||||
// Undo any private macros
|
|
||||||
#undef BOOST_PRIVATE_CTR_DEF
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BOOST_UTILITY_BASE_FROM_MEMBER_HPP
|
|
@@ -1,68 +0,0 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
|
||||||
//
|
|
||||||
// Use, modification, and distribution is subject to 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)
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/lib/optional for documentation.
|
|
||||||
//
|
|
||||||
// You are welcome to contact the author at:
|
|
||||||
// fernando_cacciola@hotmail.com
|
|
||||||
//
|
|
||||||
#ifndef BOOST_UTILITY_COMPARE_POINTEES_25AGO2003_HPP
|
|
||||||
#define BOOST_UTILITY_COMPARE_POINTEES_25AGO2003_HPP
|
|
||||||
|
|
||||||
#include<functional>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
// template<class OP> bool equal_pointees(OP const& x, OP const& y);
|
|
||||||
// template<class OP> struct equal_pointees_t;
|
|
||||||
//
|
|
||||||
// Being OP a model of OptionalPointee (either a pointer or an optional):
|
|
||||||
//
|
|
||||||
// If both x and y have valid pointees, returns the result of (*x == *y)
|
|
||||||
// If only one has a valid pointee, returns false.
|
|
||||||
// If none have valid pointees, returns true.
|
|
||||||
// No-throw
|
|
||||||
template<class OptionalPointee>
|
|
||||||
inline
|
|
||||||
bool equal_pointees ( OptionalPointee const& x, OptionalPointee const& y )
|
|
||||||
{
|
|
||||||
return (!x) != (!y) ? false : ( !x ? true : (*x) == (*y) ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class OptionalPointee>
|
|
||||||
struct equal_pointees_t : std::binary_function<OptionalPointee,OptionalPointee,bool>
|
|
||||||
{
|
|
||||||
bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const
|
|
||||||
{ return equal_pointees(x,y) ; }
|
|
||||||
} ;
|
|
||||||
|
|
||||||
// template<class OP> bool less_pointees(OP const& x, OP const& y);
|
|
||||||
// template<class OP> struct less_pointees_t;
|
|
||||||
//
|
|
||||||
// Being OP a model of OptionalPointee (either a pointer or an optional):
|
|
||||||
//
|
|
||||||
// If y has not a valid pointee, returns false.
|
|
||||||
// ElseIf x has not a valid pointee, returns true.
|
|
||||||
// ElseIf both x and y have valid pointees, returns the result of (*x < *y)
|
|
||||||
// No-throw
|
|
||||||
template<class OptionalPointee>
|
|
||||||
inline
|
|
||||||
bool less_pointees ( OptionalPointee const& x, OptionalPointee const& y )
|
|
||||||
{
|
|
||||||
return !y ? false : ( !x ? true : (*x) < (*y) ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class OptionalPointee>
|
|
||||||
struct less_pointees_t : std::binary_function<OptionalPointee,OptionalPointee,bool>
|
|
||||||
{
|
|
||||||
bool operator() ( OptionalPointee const& x, OptionalPointee const& y ) const
|
|
||||||
{ return less_pointees(x,y) ; }
|
|
||||||
} ;
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -1,33 +0,0 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
|
||||||
//
|
|
||||||
// Use, modification, and distribution is subject to 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)
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/lib/optional for documentation.
|
|
||||||
//
|
|
||||||
// You are welcome to contact the author at:
|
|
||||||
// fernando_cacciola@hotmail.com
|
|
||||||
//
|
|
||||||
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
|
||||||
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <boost/preprocessor/repetition/enum.hpp>
|
|
||||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
|
||||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
|
||||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
|
||||||
#include <boost/preprocessor/punctuation/paren.hpp>
|
|
||||||
#include <boost/preprocessor/facilities/empty.hpp>
|
|
||||||
|
|
||||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT(z,n,_) BOOST_PP_CAT(m_a,n) BOOST_PP_LPAREN() BOOST_PP_CAT(a,n) BOOST_PP_RPAREN()
|
|
||||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL(z,n,_) BOOST_PP_CAT(A,n) const& BOOST_PP_CAT(m_a,n);
|
|
||||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG(z,n,_) BOOST_PP_CAT(m_a,n)
|
|
||||||
|
|
||||||
#define BOOST_MAX_INPLACE_FACTORY_ARITY 10
|
|
||||||
|
|
||||||
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -1,23 +0,0 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
|
||||||
//
|
|
||||||
// Use, modification, and distribution is subject to 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)
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/lib/optional for documentation.
|
|
||||||
//
|
|
||||||
// You are welcome to contact the author at:
|
|
||||||
// fernando_cacciola@hotmail.com
|
|
||||||
//
|
|
||||||
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
|
||||||
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
|
||||||
|
|
||||||
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT
|
|
||||||
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL
|
|
||||||
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG
|
|
||||||
#undef BOOST_MAX_INPLACE_FACTORY_ARITY
|
|
||||||
|
|
||||||
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -1,86 +0,0 @@
|
|||||||
// Boost result_of library
|
|
||||||
|
|
||||||
// Copyright Douglas Gregor 2004. Use, modification and
|
|
||||||
// distribution is subject to 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)
|
|
||||||
|
|
||||||
// For more information, see http://www.boost.org/libs/utility
|
|
||||||
#if !defined(BOOST_PP_IS_ITERATING)
|
|
||||||
# error Boost result_of - do not include this file!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// CWPro8 requires an argument in a function type specialization
|
|
||||||
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0
|
|
||||||
# define BOOST_RESULT_OF_ARGS void
|
|
||||||
#else
|
|
||||||
# define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
|
||||||
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
|
||||||
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
|
||||||
: detail::result_of<F, F(BOOST_RESULT_OF_ARGS)> {};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
|
||||||
struct result_of<R (*)(BOOST_RESULT_OF_ARGS), FArgs>
|
|
||||||
{
|
|
||||||
typedef R type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
|
||||||
struct result_of<R (&)(BOOST_RESULT_OF_ARGS), FArgs>
|
|
||||||
{
|
|
||||||
typedef R type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#undef BOOST_RESULT_OF_ARGS
|
|
||||||
|
|
||||||
#if BOOST_PP_ITERATION() > 1 && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
|
||||||
struct result_of<R (T0::*)
|
|
||||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),
|
|
||||||
FArgs>
|
|
||||||
{
|
|
||||||
typedef R type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
|
||||||
struct result_of<R (T0::*)
|
|
||||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
|
||||||
const,
|
|
||||||
FArgs>
|
|
||||||
{
|
|
||||||
typedef R type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
|
||||||
struct result_of<R (T0::*)
|
|
||||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
|
||||||
volatile,
|
|
||||||
FArgs>
|
|
||||||
{
|
|
||||||
typedef R type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
|
||||||
struct result_of<R (T0::*)
|
|
||||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
|
||||||
const volatile,
|
|
||||||
FArgs>
|
|
||||||
{
|
|
||||||
typedef R type;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
@@ -1,119 +0,0 @@
|
|||||||
// Boost enable_if library
|
|
||||||
|
|
||||||
// Copyright 2003 <20> The Trustees of Indiana University.
|
|
||||||
|
|
||||||
// Use, modification, and distribution is subject to 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)
|
|
||||||
|
|
||||||
// Authors: Jaakko J<>rvi (jajarvi at osl.iu.edu)
|
|
||||||
// Jeremiah Willcock (jewillco at osl.iu.edu)
|
|
||||||
// Andrew Lumsdaine (lums at osl.iu.edu)
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BOOST_UTILITY_ENABLE_IF_HPP
|
|
||||||
#define BOOST_UTILITY_ENABLE_IF_HPP
|
|
||||||
|
|
||||||
#include "boost/config.hpp"
|
|
||||||
|
|
||||||
// Even the definition of enable_if causes problems on some compilers,
|
|
||||||
// so it's macroed out for all compilers that do not support SFINAE
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_SFINAE
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
template <bool B, class T = void>
|
|
||||||
struct enable_if_c {
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct enable_if_c<false, T> {};
|
|
||||||
|
|
||||||
template <class Cond, class T = void>
|
|
||||||
struct enable_if : public enable_if_c<Cond::value, T> {};
|
|
||||||
|
|
||||||
template <bool B, class T>
|
|
||||||
struct lazy_enable_if_c {
|
|
||||||
typedef typename T::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct lazy_enable_if_c<false, T> {};
|
|
||||||
|
|
||||||
template <class Cond, class T>
|
|
||||||
struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
|
|
||||||
|
|
||||||
|
|
||||||
template <bool B, class T = void>
|
|
||||||
struct disable_if_c {
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct disable_if_c<true, T> {};
|
|
||||||
|
|
||||||
template <class Cond, class T = void>
|
|
||||||
struct disable_if : public disable_if_c<Cond::value, T> {};
|
|
||||||
|
|
||||||
template <bool B, class T>
|
|
||||||
struct lazy_disable_if_c {
|
|
||||||
typedef typename T::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct lazy_disable_if_c<true, T> {};
|
|
||||||
|
|
||||||
template <class Cond, class T>
|
|
||||||
struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
namespace detail { typedef void enable_if_default_T; }
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct enable_if_does_not_work_on_this_compiler;
|
|
||||||
|
|
||||||
template <bool B, class T = detail::enable_if_default_T>
|
|
||||||
struct enable_if_c : enable_if_does_not_work_on_this_compiler<T>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template <bool B, class T = detail::enable_if_default_T>
|
|
||||||
struct disable_if_c : enable_if_does_not_work_on_this_compiler<T>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template <bool B, class T = detail::enable_if_default_T>
|
|
||||||
struct lazy_enable_if_c : enable_if_does_not_work_on_this_compiler<T>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template <bool B, class T = detail::enable_if_default_T>
|
|
||||||
struct lazy_disable_if_c : enable_if_does_not_work_on_this_compiler<T>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template <class Cond, class T = detail::enable_if_default_T>
|
|
||||||
struct enable_if : enable_if_does_not_work_on_this_compiler<T>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template <class Cond, class T = detail::enable_if_default_T>
|
|
||||||
struct disable_if : enable_if_does_not_work_on_this_compiler<T>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template <class Cond, class T = detail::enable_if_default_T>
|
|
||||||
struct lazy_enable_if : enable_if_does_not_work_on_this_compiler<T>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template <class Cond, class T = detail::enable_if_default_T>
|
|
||||||
struct lazy_disable_if : enable_if_does_not_work_on_this_compiler<T>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif // BOOST_NO_SFINAE
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,58 +0,0 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
|
||||||
//
|
|
||||||
// Use, modification, and distribution is subject to 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)
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/lib/optional for documentation.
|
|
||||||
//
|
|
||||||
// You are welcome to contact the author at:
|
|
||||||
// fernando_cacciola@hotmail.com
|
|
||||||
//
|
|
||||||
#ifndef BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
|
|
||||||
#define BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
|
|
||||||
|
|
||||||
#include <boost/utility/detail/in_place_factory_prefix.hpp>
|
|
||||||
|
|
||||||
#include <boost/type.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
class in_place_factory_base {} ;
|
|
||||||
|
|
||||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS(z,n,_) \
|
|
||||||
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
|
||||||
class BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) : public in_place_factory_base \
|
|
||||||
{ \
|
|
||||||
public: \
|
|
||||||
\
|
|
||||||
BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \
|
|
||||||
: \
|
|
||||||
BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \
|
|
||||||
{} \
|
|
||||||
\
|
|
||||||
template<class T> \
|
|
||||||
void apply ( void* address BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) ) const \
|
|
||||||
{ \
|
|
||||||
new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
|
|
||||||
} ; \
|
|
||||||
\
|
|
||||||
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
|
||||||
BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
|
||||||
in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
|
|
||||||
{ \
|
|
||||||
return BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
|
||||||
( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
|
|
||||||
} ; \
|
|
||||||
|
|
||||||
BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#include <boost/utility/detail/in_place_factory_suffix.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -1,66 +0,0 @@
|
|||||||
// Boost result_of library
|
|
||||||
|
|
||||||
// Copyright Douglas Gregor 2004. Use, modification and
|
|
||||||
// distribution is subject to 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)
|
|
||||||
|
|
||||||
// For more information, see http://www.boost.org/libs/utility
|
|
||||||
#ifndef BOOST_RESULT_OF_HPP
|
|
||||||
#define BOOST_RESULT_OF_HPP
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <boost/type_traits/ice.hpp>
|
|
||||||
#include <boost/type.hpp>
|
|
||||||
#include <boost/preprocessor.hpp>
|
|
||||||
#include <boost/detail/workaround.hpp>
|
|
||||||
#include <boost/mpl/has_xxx.hpp>
|
|
||||||
|
|
||||||
#ifndef BOOST_RESULT_OF_NUM_ARGS
|
|
||||||
# define BOOST_RESULT_OF_NUM_ARGS 10
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
template<typename F> struct result_of;
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
|
|
||||||
|
|
||||||
template<typename F, typename FArgs, bool HasResultType> struct get_result_of;
|
|
||||||
|
|
||||||
template<typename F, typename FArgs>
|
|
||||||
struct get_result_of<F, FArgs, true>
|
|
||||||
{
|
|
||||||
typedef typename F::result_type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename F, typename FArgs>
|
|
||||||
struct get_result_of<F, FArgs, false>
|
|
||||||
{
|
|
||||||
typedef typename F::template result<FArgs>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename F>
|
|
||||||
struct get_result_of<F, F(void), false>
|
|
||||||
{
|
|
||||||
typedef void type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename F, typename FArgs>
|
|
||||||
struct result_of : get_result_of<F, FArgs, (has_result_type<F>::value)> {};
|
|
||||||
|
|
||||||
} // end namespace detail
|
|
||||||
|
|
||||||
#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
|
|
||||||
#include BOOST_PP_ITERATE()
|
|
||||||
|
|
||||||
#else
|
|
||||||
# define BOOST_NO_RESULT_OF 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BOOST_RESULT_OF_HPP
|
|
@@ -1,57 +0,0 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
|
||||||
//
|
|
||||||
// Use, modification, and distribution is subject to 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)
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/lib/optional for documentation.
|
|
||||||
//
|
|
||||||
// You are welcome to contact the author at:
|
|
||||||
// fernando_cacciola@hotmail.com
|
|
||||||
//
|
|
||||||
#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
|
|
||||||
#define BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
|
|
||||||
|
|
||||||
#include <boost/utility/detail/in_place_factory_prefix.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
class typed_in_place_factory_base {} ;
|
|
||||||
|
|
||||||
#define BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS(z,n,_) \
|
|
||||||
template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
|
||||||
class BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) : public typed_in_place_factory_base \
|
|
||||||
{ \
|
|
||||||
public: \
|
|
||||||
\
|
|
||||||
typedef T value_type ; \
|
|
||||||
\
|
|
||||||
BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \
|
|
||||||
: \
|
|
||||||
BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \
|
|
||||||
{} \
|
|
||||||
\
|
|
||||||
void apply ( void* address ) const \
|
|
||||||
{ \
|
|
||||||
new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
|
|
||||||
} ; \
|
|
||||||
\
|
|
||||||
template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
|
||||||
BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T , BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
|
||||||
in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
|
|
||||||
{ \
|
|
||||||
return BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T, BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
|
||||||
( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
|
|
||||||
} ; \
|
|
||||||
|
|
||||||
BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#include <boost/utility/detail/in_place_factory_suffix.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@@ -1,77 +0,0 @@
|
|||||||
// (C) 2002, Fernando Luis Cacciola Carballal.
|
|
||||||
//
|
|
||||||
// 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)
|
|
||||||
//
|
|
||||||
// 21 Ago 2002 (Created) Fernando Cacciola
|
|
||||||
//
|
|
||||||
#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
|
||||||
#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
|
||||||
|
|
||||||
#include "boost/detail/select_type.hpp"
|
|
||||||
#include "boost/type_traits/cv_traits.hpp"
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
|
|
||||||
namespace vinit_detail {
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class const_T_base
|
|
||||||
{
|
|
||||||
protected :
|
|
||||||
|
|
||||||
const_T_base() : x() {}
|
|
||||||
|
|
||||||
T x ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct non_const_T_base
|
|
||||||
{
|
|
||||||
protected :
|
|
||||||
|
|
||||||
non_const_T_base() : x() {}
|
|
||||||
|
|
||||||
mutable T x ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct select_base
|
|
||||||
{
|
|
||||||
typedef typename
|
|
||||||
detail::if_true< ::boost::is_const<T>::value >
|
|
||||||
::template then< const_T_base<T>, non_const_T_base<T> >::type type ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
} // namespace vinit_detail
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class value_initialized : private vinit_detail::select_base<T>::type
|
|
||||||
{
|
|
||||||
public :
|
|
||||||
|
|
||||||
value_initialized() {}
|
|
||||||
|
|
||||||
operator T&() const { return this->x ; }
|
|
||||||
|
|
||||||
T& data() const { return this->x ; }
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
T const& get ( value_initialized<T> const& x )
|
|
||||||
{
|
|
||||||
return x.data() ;
|
|
||||||
}
|
|
||||||
template<class T>
|
|
||||||
T& get ( value_initialized<T>& x )
|
|
||||||
{
|
|
||||||
return x.data() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
27
iter_adaptor_fail_expected1.cpp
Normal file
27
iter_adaptor_fail_expected1.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// Test boost/pending/iterator_adaptors.hpp
|
||||||
|
|
||||||
|
// (C) Copyright Jeremy Siek 1999. Permission to copy, use, modify,
|
||||||
|
// sell and distribute this software is granted provided this
|
||||||
|
// copyright notice appears in all copies. This software is provided
|
||||||
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
|
// to its suitability for any purpose.
|
||||||
|
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
// Revision History
|
||||||
|
// 21 Jan 01 Initial version (Jeremy Siek)
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <list>
|
||||||
|
#include <boost/pending/iterator_adaptors.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
typedef boost::iterator_adaptor<std::list<int>::iterator,
|
||||||
|
boost::default_iterator_policies,
|
||||||
|
int,int&,int*,std::bidirectional_iterator_tag> adaptor_type;
|
||||||
|
|
||||||
|
adaptor_type i;
|
||||||
|
i += 4;
|
||||||
|
return 0;
|
||||||
|
}
|
28
iter_adaptor_fail_expected2.cpp
Normal file
28
iter_adaptor_fail_expected2.cpp
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
// Test boost/pending/iterator_adaptors.hpp
|
||||||
|
|
||||||
|
// (C) Copyright Jeremy Siek 1999. Permission to copy, use, modify,
|
||||||
|
// sell and distribute this software is granted provided this
|
||||||
|
// copyright notice appears in all copies. This software is provided
|
||||||
|
// "as is" without express or implied warranty, and with no claim as
|
||||||
|
// to its suitability for any purpose.
|
||||||
|
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
// Revision History
|
||||||
|
// 21 Jan 01 Initial version (Jeremy Siek)
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <boost/pending/iterator_adaptors.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
typedef boost::iterator_adaptor<std::istream_iterator<int>,
|
||||||
|
boost::default_iterator_policies,
|
||||||
|
int,int&,int*,std::input_iterator_tag> adaptor_type;
|
||||||
|
|
||||||
|
adaptor_type iter;
|
||||||
|
--iter;
|
||||||
|
return 0;
|
||||||
|
}
|
96
projection_iterator_example.cpp
Normal file
96
projection_iterator_example.cpp
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify, sell and
|
||||||
|
// distribute this software is granted provided this copyright notice appears
|
||||||
|
// in all copies. This software is provided "as is" without express or implied
|
||||||
|
// warranty, and with no claim as to its suitability for any purpose.
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <list>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
#include <boost/iterator_adaptors.hpp>
|
||||||
|
|
||||||
|
struct personnel_record {
|
||||||
|
personnel_record(std::string n, int id) : m_name(n), m_ID(id) { }
|
||||||
|
std::string m_name;
|
||||||
|
int m_ID;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct select_name {
|
||||||
|
typedef personnel_record argument_type;
|
||||||
|
typedef std::string result_type;
|
||||||
|
const std::string& operator()(const personnel_record& r) const {
|
||||||
|
return r.m_name;
|
||||||
|
}
|
||||||
|
std::string& operator()(personnel_record& r) const {
|
||||||
|
return r.m_name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct select_ID {
|
||||||
|
typedef personnel_record argument_type;
|
||||||
|
typedef int result_type;
|
||||||
|
const int& operator()(const personnel_record& r) const {
|
||||||
|
return r.m_ID;
|
||||||
|
}
|
||||||
|
int& operator()(personnel_record& r) const {
|
||||||
|
return r.m_ID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int, char*[])
|
||||||
|
{
|
||||||
|
std::list<personnel_record> personnel_list;
|
||||||
|
|
||||||
|
personnel_list.push_back(personnel_record("Barney", 13423));
|
||||||
|
personnel_list.push_back(personnel_record("Fred", 12343));
|
||||||
|
personnel_list.push_back(personnel_record("Wilma", 62454));
|
||||||
|
personnel_list.push_back(personnel_record("Betty", 20490));
|
||||||
|
|
||||||
|
// Example of using projection_iterator_generator
|
||||||
|
// to print out the names in the personnel list.
|
||||||
|
|
||||||
|
boost::projection_iterator_generator<select_name,
|
||||||
|
std::list<personnel_record>::iterator>::type
|
||||||
|
personnel_first(personnel_list.begin()),
|
||||||
|
personnel_last(personnel_list.end());
|
||||||
|
|
||||||
|
std::copy(personnel_first, personnel_last,
|
||||||
|
std::ostream_iterator<std::string>(std::cout, "\n"));
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
// Example of using projection_iterator_pair_generator
|
||||||
|
// to assign new ID numbers to the personnel.
|
||||||
|
|
||||||
|
typedef boost::projection_iterator_pair_generator<select_ID,
|
||||||
|
std::list<personnel_record>::iterator,
|
||||||
|
std::list<personnel_record>::const_iterator> PairGen;
|
||||||
|
|
||||||
|
PairGen::iterator ID_first(personnel_list.begin()),
|
||||||
|
ID_last(personnel_list.end());
|
||||||
|
|
||||||
|
int new_id = 0;
|
||||||
|
while (ID_first != ID_last) {
|
||||||
|
*ID_first = new_id++;
|
||||||
|
++ID_first;
|
||||||
|
}
|
||||||
|
|
||||||
|
PairGen::const_iterator const_ID_first(personnel_list.begin()),
|
||||||
|
const_ID_last(personnel_list.end());
|
||||||
|
|
||||||
|
std::copy(const_ID_first, const_ID_last,
|
||||||
|
std::ostream_iterator<int>(std::cout, " "));
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
// Example of using make_const_projection_iterator()
|
||||||
|
// to print out the names in the personnel list again.
|
||||||
|
|
||||||
|
std::copy
|
||||||
|
(boost::make_const_projection_iterator<select_name>(personnel_list.begin()),
|
||||||
|
boost::make_const_projection_iterator<select_name>(personnel_list.end()),
|
||||||
|
std::ostream_iterator<std::string>(std::cout, "\n"));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
42
reverse_iterator_example.cpp
Normal file
42
reverse_iterator_example.cpp
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify, sell and
|
||||||
|
// distribute this software is granted provided this copyright notice appears
|
||||||
|
// in all copies. This software is provided "as is" without express or implied
|
||||||
|
// warranty, and with no claim as to its suitability for any purpose.
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <boost/iterator_adaptors.hpp>
|
||||||
|
|
||||||
|
int main(int, char*[])
|
||||||
|
{
|
||||||
|
char letters[] = "hello world!";
|
||||||
|
const int N = sizeof(letters)/sizeof(char) - 1;
|
||||||
|
std::cout << "original sequence of letters:\t"
|
||||||
|
<< letters << std::endl;
|
||||||
|
|
||||||
|
std::sort(letters, letters + N);
|
||||||
|
|
||||||
|
// Use reverse_iterator_generator to print a sequence
|
||||||
|
// of letters in reverse order.
|
||||||
|
|
||||||
|
boost::reverse_iterator_generator<char*>::type
|
||||||
|
reverse_letters_first(letters + N),
|
||||||
|
reverse_letters_last(letters);
|
||||||
|
|
||||||
|
std::cout << "letters in descending order:\t";
|
||||||
|
std::copy(reverse_letters_first, reverse_letters_last,
|
||||||
|
std::ostream_iterator<char>(std::cout));
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
// Use make_reverse_iterator() to print the sequence
|
||||||
|
// of letters in reverse-reverse order.
|
||||||
|
|
||||||
|
std::cout << "letters in ascending order:\t";
|
||||||
|
std::copy(boost::make_reverse_iterator(reverse_letters_last),
|
||||||
|
boost::make_reverse_iterator(reverse_letters_first),
|
||||||
|
std::ostream_iterator<char>(std::cout));
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
44
transform_iterator_example.cpp
Normal file
44
transform_iterator_example.cpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify, sell and
|
||||||
|
// distribute this software is granted provided this copyright notice appears
|
||||||
|
// in all copies. This software is provided "as is" without express or implied
|
||||||
|
// warranty, and with no claim as to its suitability for any purpose.
|
||||||
|
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <boost/iterator_adaptors.hpp>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int, char*[])
|
||||||
|
{
|
||||||
|
// This is a simple example of using the transform_iterators class to
|
||||||
|
// generate iterators that multiply the value returned by dereferencing
|
||||||
|
// the iterator. In this case we are multiplying by 2.
|
||||||
|
// Would be cooler to use lambda library in this example.
|
||||||
|
|
||||||
|
int x[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||||
|
const int N = sizeof(x)/sizeof(int);
|
||||||
|
|
||||||
|
typedef std::binder1st< std::multiplies<int> > Function;
|
||||||
|
typedef boost::transform_iterator_generator<Function, int*>::type doubling_iterator;
|
||||||
|
|
||||||
|
doubling_iterator i(x, std::bind1st(std::multiplies<int>(), 2)),
|
||||||
|
i_end(x + N, std::bind1st(std::multiplies<int>(), 2));
|
||||||
|
|
||||||
|
std::cout << "multiplying the array by 2:" << std::endl;
|
||||||
|
while (i != i_end)
|
||||||
|
std::cout << *i++ << " ";
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
std::cout << "adding 4 to each element in the array:" << std::endl;
|
||||||
|
|
||||||
|
std::copy(boost::make_transform_iterator(x, std::bind1st(std::plus<int>(), 4)),
|
||||||
|
boost::make_transform_iterator(x + N, std::bind1st(std::plus<int>(), 4)),
|
||||||
|
std::ostream_iterator<int>(std::cout, " "));
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user