• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10 
11 #ifndef BOOST_COMPUTE_ITERATOR_DETAIL_GET_BASE_ITERATOR_BUFFER_HPP
12 #define BOOST_COMPUTE_ITERATOR_DETAIL_GET_BASE_ITERATOR_BUFFER_HPP
13 
14 namespace boost {
15 namespace compute {
16 namespace detail {
17 
18 // returns the buffer for an iterator adaptor's base iterator if
19 // it exists, otherwise returns a null buffer object.
20 template<class Iterator>
21 inline const buffer&
get_base_iterator_buffer(const Iterator & iter,typename boost::enable_if<is_buffer_iterator<typename Iterator::base_type>>::type * =0)22 get_base_iterator_buffer(const Iterator &iter,
23                          typename boost::enable_if<
24                              is_buffer_iterator<
25                                  typename Iterator::base_type
26                              >
27                          >::type* = 0)
28 {
29     return iter.base().get_buffer();
30 }
31 
32 template<class Iterator>
33 inline const buffer&
get_base_iterator_buffer(const Iterator & iter,typename boost::disable_if<is_buffer_iterator<typename Iterator::base_type>>::type * =0)34 get_base_iterator_buffer(const Iterator &iter,
35                          typename boost::disable_if<
36                              is_buffer_iterator<
37                                  typename Iterator::base_type
38                              >
39                          >::type* = 0)
40 {
41     (void) iter;
42 
43     static buffer null_buffer;
44 
45     return null_buffer;
46 }
47 
48 } // end detail namespace
49 } // end compute namespace
50 } // end boost namespace
51 
52 #endif // BOOST_COMPUTE_ITERATOR_DETAIL_GET_BASE_ITERATOR_BUFFER_HPP
53