Files
fusion/test/sequence/ext_/iterator_range_s.cpp
Eric Niebler 798b2f4017 Merged revisions 41072-41140 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r41077 | troyer | 2007-11-13 23:00:02 -0800 (Tue, 13 Nov 2007) | 1 line
  
  Added support for std::complex to serialization
........
  r41078 | joaquin | 2007-11-13 23:09:29 -0800 (Tue, 13 Nov 2007) | 1 line
  
  added missing include
........
  r41079 | djowel | 2007-11-14 02:13:51 -0800 (Wed, 14 Nov 2007) | 1 line
  
  adjust to compensate for lack of <small> tag.
........
  r41080 | djowel | 2007-11-14 02:17:09 -0800 (Wed, 14 Nov 2007) | 1 line
  
  refresh docs
........
  r41081 | djowel | 2007-11-14 02:23:23 -0800 (Wed, 14 Nov 2007) | 1 line
  
  refresh docs
........
  r41082 | djowel | 2007-11-14 02:24:21 -0800 (Wed, 14 Nov 2007) | 1 line
  
  refresh docs
........
  r41083 | anthonyw | 2007-11-14 03:08:09 -0800 (Wed, 14 Nov 2007) | 1 line
  
  ignore and join all threads in group on exception
........
  r41084 | anthonyw | 2007-11-14 03:56:53 -0800 (Wed, 14 Nov 2007) | 1 line
  
  interrupt and join all threads in a group if an exception is thrown during a test
........
  r41086 | johnmaddock | 2007-11-14 04:14:19 -0800 (Wed, 14 Nov 2007) | 1 line
  
  Merged changes from the Sandbox to Trunk.
........
  r41087 | anthonyw | 2007-11-14 04:17:41 -0800 (Wed, 14 Nov 2007) | 1 line
  
  interrupt and join all threads in a group if an exception is thrown during a test
........
  r41088 | johnmaddock | 2007-11-14 04:41:32 -0800 (Wed, 14 Nov 2007) | 1 line
  
  Added WinCE workaround.
........
  r41089 | johnmaddock | 2007-11-14 05:03:15 -0800 (Wed, 14 Nov 2007) | 1 line
  
  Catch exceptions thrown from thread creation.
........
  r41090 | anthonyw | 2007-11-14 06:49:58 -0800 (Wed, 14 Nov 2007) | 1 line
  
  fixes for pthread implementation
........
  r41091 | bemandawes | 2007-11-14 07:50:43 -0800 (Wed, 14 Nov 2007) | 1 line
  
  Replace old docs with excerpts from http://article.gmane.org/gmane.comp.lib.boost.testing/5020
........
  r41093 | eric_niebler | 2007-11-14 08:36:15 -0800 (Wed, 14 Nov 2007) | 1 line
  
  fix support for segmented iteration
........
  r41094 | dave | 2007-11-14 09:37:55 -0800 (Wed, 14 Nov 2007) | 3 lines
  
  Update command-prompt instructions per
  http://news.gmane.org/find-root.php?message_id=%3cfhcrem%24c4%241%40ger.gmane.org%3e
........
  r41095 | bemandawes | 2007-11-14 12:05:30 -0800 (Wed, 14 Nov 2007) | 1 line
  
  Bring docs more in line with reality:-)
........
  r41097 | hljin | 2007-11-14 18:07:53 -0800 (Wed, 14 Nov 2007) | 1 line
  
  GIL: removed the example directory from the documentation as it is a duplication and re-directed the Doxygen documentation to a local copy (to be submitted next)
........
  r41098 | hljin | 2007-11-14 18:30:13 -0800 (Wed, 14 Nov 2007) | 1 line
  
  GIL: added a local copy of the Doxygen documentation
........
  r41099 | hljin | 2007-11-14 18:32:04 -0800 (Wed, 14 Nov 2007) | 1 line
  
  GIL: added a local copy of the Doxygen documentation (second batch)
........
  r41100 | chris_kohlhoff | 2007-11-14 22:19:04 -0800 (Wed, 14 Nov 2007) | 6 lines
  
  Try to fix an order-of-initialisation problem with error_category references.
  The symptom, which only occurs in some applications, is a crash due to a
  dereference of a null pointer. The exact conditions under which the problem
  occurs are not fully understood, so this fix is probably more paranoid than
  necessary.
........
  r41102 | jhunold | 2007-11-14 23:04:24 -0800 (Wed, 14 Nov 2007) | 1 line
  
  Suppress msvc "deprecated" warnings.
........
  r41103 | johnmaddock | 2007-11-15 01:52:26 -0800 (Thu, 15 Nov 2007) | 1 line
  
  Fix some compiler warnings when building with the Intel and aCC compilers.
........
  r41104 | garcia | 2007-11-15 04:50:48 -0800 (Thu, 15 Nov 2007) | 2 lines
  
  John Torjo is reviewing the X-files.
........
  r41105 | hkaiser | 2007-11-15 05:27:24 -0800 (Thu, 15 Nov 2007) | 1 line
  
  Suppressed more warnings during build of Wave.
........
  r41106 | bemandawes | 2007-11-15 06:36:40 -0800 (Thu, 15 Nov 2007) | 1 line
  
  GetUserDefaultUILanguage isn't present for Cygwin, so disable use
........
  r41107 | bemandawes | 2007-11-15 07:20:27 -0800 (Thu, 15 Nov 2007) | 1 line
  
  Get rid of .cvsignore files
........
  r41108 | eric_niebler | 2007-11-15 08:06:22 -0800 (Thu, 15 Nov 2007) | 1 line
  
  fix typo
........
  r41110 | grafik | 2007-11-15 08:58:21 -0800 (Thu, 15 Nov 2007) | 1 line
  
  Fix building of multiple regression tools at once.
........
  r41111 | gmelquio | 2007-11-15 09:52:31 -0800 (Thu, 15 Nov 2007) | 1 line
  
  Fixed documentation typo.
........
  r41113 | grafik | 2007-11-15 10:56:43 -0800 (Thu, 15 Nov 2007) | 1 line
  
  Switch intel-win32 to use static multi thread runtime since the single thread static runtime is no longer available. (fixes #1287)
........
  r41114 | andreas_huber69 | 2007-11-15 11:22:12 -0800 (Thu, 15 Nov 2007) | 1 line
  
  Added new FAQ item suggested by Chris Paulse.
........
  r41116 | guwi17 | 2007-11-15 12:52:37 -0800 (Thu, 15 Nov 2007) | 4 lines
  
  This patch now lets the Sun compiler work for most of uBLAS. 'test4' is now failing.
  Too avoid other compilers complaining about missing return values in some functions where exceptions are thrown, code was added so an arbitatry were chosen.
........
  r41117 | danmarsden | 2007-11-15 13:15:47 -0800 (Thu, 15 Nov 2007) | 1 line
  
  removing failing test on EDG compilers
........
  r41118 | grafik | 2007-11-15 14:05:15 -0800 (Thu, 15 Nov 2007) | 1 line
  
  Remove redundant reference to system library. It causes double linking when used indirectly through filesystem. Which can lead to double linking incompatible variants when a specific filesystem variant is requested.
........
  r41119 | grafik | 2007-11-15 14:05:22 -0800 (Thu, 15 Nov 2007) | 1 line
  
  Oops, forgot we need to use the root boost project settings when building.
........


[SVN r41141]
2007-11-16 08:03:15 +00:00

147 lines
4.5 KiB
C++
Executable File

/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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)
==============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/algorithm/iteration/ext_/for_each_s.hpp>
#include <boost/fusion/algorithm/query/ext_/find_if_s.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/container/ext_/tree.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/view/iterator_range/iterator_range.hpp>
#include <boost/fusion/view/ext_/segmented_iterator_range.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/begin.hpp>
#include <boost/mpl/next.hpp>
#include <boost/static_assert.hpp>
#include <sstream>
struct ostream_fun
{
ostream_fun(std::ostream &sout)
: sout_(sout)
{}
template<typename T>
void operator ()(T const &t) const
{
sout_ << t << ' ';
}
private:
std::ostream & sout_;
};
template<typename Tree>
void
process_tree(Tree const &tree)
{
using namespace boost;
using namespace fusion;
using mpl::_;
typedef typename fusion::result_of::find_if_s<Tree const, is_same<_,short> >::type short_iter;
typedef typename fusion::result_of::find_if_s<Tree const, is_same<_,float> >::type float_iter;
typedef iterator_range<short_iter, float_iter> slice_t;
BOOST_STATIC_ASSERT(traits::is_segmented<slice_t>::value);
// find_if_s of a segmented data structure returns generic
// segmented iterators
short_iter si = find_if_s<is_same<_,short> >(tree);
float_iter fi = find_if_s<is_same<_,float> >(tree);
// If you put them in an iterator range, the range
// is automatically a segmented data structure.
slice_t slice(si, fi);
std::stringstream sout;
fusion::for_each_s(slice, ostream_fun(sout));
BOOST_TEST((sout.str() == "100 e f 0 B "));
}
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
{
char const* s = "Ruby";
typedef vector<int, char, double, char const*> vector_type;
vector_type vec(1, 'x', 3.3, s);
{
typedef vector_iterator<vector_type, 1> i1t;
typedef vector_iterator<vector_type, 3> i3t;
i1t i1(vec);
i3t i3(vec);
typedef iterator_range<i1t, i3t> slice_t;
slice_t slice(i1, i3);
std::cout << slice << std::endl;
BOOST_TEST((slice == make_vector('x', 3.3)));
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
}
{
typedef vector_iterator<vector_type, 0> i1t;
typedef vector_iterator<vector_type, 0> i3t;
i1t i1(vec);
i3t i3(vec);
typedef iterator_range<i1t, i3t> slice_t;
slice_t slice(i1, i3);
std::cout << slice << std::endl;
BOOST_TEST(slice == make_vector());
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 0);
}
}
{
typedef boost::mpl::vector_c<int, 2, 3, 4, 5, 6> mpl_vec;
typedef boost::mpl::begin<mpl_vec>::type it0;
typedef boost::mpl::next<it0>::type it1;
typedef boost::mpl::next<it1>::type it2;
typedef boost::mpl::next<it2>::type it3;
it1 f;
it3 l;
typedef iterator_range<it1, it3> slice_t;
slice_t slice(f, l);
std::cout << slice << std::endl;
BOOST_TEST((slice == make_vector(3, 4)));
BOOST_STATIC_ASSERT(result_of::size<slice_t>::value == 2);
}
{
process_tree(
make_tree(
make_vector(double(0),'B')
, make_tree(
make_vector(1,2,long(3))
, make_tree(make_vector('a','b','c'))
, make_tree(make_vector(short('d'),'e','f'))
)
, make_tree(
make_vector(4,5,6)
, make_tree(make_vector(float(1),'h','i'))
, make_tree(make_vector('j','k','l'))
)
)
);
}
return boost::report_errors();
}