]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/wave/include/boost/wave/util/transform_iterator.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / wave / include / boost / wave / util / transform_iterator.hpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Boost.Wave: A Standard compliant C++ preprocessor library
3
4 http://www.boost.org/
5
6 Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
7 Software License, Version 1.0. (See accompanying file
8 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9=============================================================================*/
10
11#if !defined(TRANSFORM_ITERATOR_HPP_D492C659_88C7_4258_8C42_192F9AE80EC0_INCLUDED)
12#define TRANSFORM_ITERATOR_HPP_D492C659_88C7_4258_8C42_192F9AE80EC0_INCLUDED
13
14#include <boost/config.hpp>
15#include <boost/iterator_adaptors.hpp>
16#include <boost/iterator/transform_iterator.hpp>
17
18#include <boost/assert.hpp>
19
20// this must occur after all of the includes and before any code appears
21#ifdef BOOST_HAS_ABI_HEADERS
22#include BOOST_ABI_PREFIX
23#endif
24
25///////////////////////////////////////////////////////////////////////////////
26namespace boost {
27namespace wave {
28namespace impl {
29
30///////////////////////////////////////////////////////////////////////////////
31//
32// The new Boost.Iterator library already conatins a transform_iterator usable
33// for our needs. The code below wraps this up.
34//
35///////////////////////////////////////////////////////////////////////////////
36 template <class AdaptableUnaryFunctionT, class IteratorT>
37 class ref_transform_iterator_generator
38 {
39 typedef typename AdaptableUnaryFunctionT::result_type return_type;
40 typedef typename AdaptableUnaryFunctionT::argument_type argument_type;
41
42 public:
43 typedef boost::transform_iterator<
44 return_type (*)(argument_type), IteratorT, return_type>
45 type;
46 };
47
48 template <class AdaptableUnaryFunctionT, class IteratorT>
49 inline
50 typename ref_transform_iterator_generator<
51 AdaptableUnaryFunctionT, IteratorT>::type
52 make_ref_transform_iterator(
53 IteratorT base, AdaptableUnaryFunctionT const &f)
54 {
55 typedef typename ref_transform_iterator_generator<
56 AdaptableUnaryFunctionT, IteratorT>::type
57 iterator_type;
58 return iterator_type(base, f.transform);
59 }
60
61 // Retrieve the token value given a parse node
62 // This is used in conjunction with the ref_transform_iterator above, to
63 // get the token values while iterating directly over the parse tree.
64 template <typename TokenT, typename ParseTreeNodeT>
65 struct get_token_value {
66
67 typedef TokenT const &result_type;
68 typedef ParseTreeNodeT const &argument_type;
69
70 static result_type
71 transform (argument_type node)
72 {
73 BOOST_ASSERT(1 == std::distance(node.value.begin(),
74 node.value.end()));
75 return *node.value.begin();
76 }
77 };
78
79///////////////////////////////////////////////////////////////////////////////
80} // namespace impl
81} // namespace wave
82} // namespace boost
83
84// the suffix header occurs after all of the code
85#ifdef BOOST_HAS_ABI_HEADERS
86#include BOOST_ABI_SUFFIX
87#endif
88
89#endif // !defined(TRANSFORM_ITERATOR_HPP_D492C659_88C7_4258_8C42_192F9AE80EC0_INCLUDED)