get_base_iterator_buffer.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef BOOST_COMPUTE_ITERATOR_DETAIL_GET_BASE_ITERATOR_BUFFER_HPP
  11. #define BOOST_COMPUTE_ITERATOR_DETAIL_GET_BASE_ITERATOR_BUFFER_HPP
  12. namespace boost {
  13. namespace compute {
  14. namespace detail {
  15. // returns the buffer for an iterator adaptor's base iterator if
  16. // it exists, otherwise returns a null buffer object.
  17. template<class Iterator>
  18. inline const buffer&
  19. get_base_iterator_buffer(const Iterator &iter,
  20. typename boost::enable_if<
  21. is_buffer_iterator<
  22. typename Iterator::base_type
  23. >
  24. >::type* = 0)
  25. {
  26. return iter.base().get_buffer();
  27. }
  28. template<class Iterator>
  29. inline const buffer&
  30. get_base_iterator_buffer(const Iterator &iter,
  31. typename boost::disable_if<
  32. is_buffer_iterator<
  33. typename Iterator::base_type
  34. >
  35. >::type* = 0)
  36. {
  37. (void) iter;
  38. static buffer null_buffer;
  39. return null_buffer;
  40. }
  41. } // end detail namespace
  42. } // end compute namespace
  43. } // end boost namespace
  44. #endif // BOOST_COMPUTE_ITERATOR_DETAIL_GET_BASE_ITERATOR_BUFFER_HPP