basic_reduce.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2005 The Trustees of Indiana University.
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Authors: Douglas Gregor
  6. // Andrew Lumsdaine
  7. #ifndef BOOST_PARALLEL_BASIC_REDUCE_HPP
  8. #define BOOST_PARALLEL_BASIC_REDUCE_HPP
  9. namespace boost { namespace parallel {
  10. /** Reduction operation used to reconcile differences between local
  11. * and remote values for a particular key in a property map. The
  12. * type @c T is typically the @c value_type of the property
  13. * map. This basic reduction returns a default-constructed @c T as
  14. * the default value and always resolves to the remote value.
  15. */
  16. template<typename T>
  17. struct basic_reduce
  18. {
  19. BOOST_STATIC_CONSTANT(bool, non_default_resolver = false);
  20. /// Returns a default-constructed T object
  21. template<typename Key>
  22. T operator()(const Key&) const { return T(); }
  23. /// Returns the remote value
  24. template<typename Key>
  25. const T& operator()(const Key&, const T&, const T& remote) const
  26. { return remote; }
  27. };
  28. } } // end namespace boost::parallel
  29. #endif // BOOST_PARALLEL_BASIC_REDUCE_HPP