make_default.hpp 710 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2015-2019 Hans Dembinski
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_HISTOGRAM_DETAIL_MAKE_DEFAULT_HPP
  7. #define BOOST_HISTOGRAM_DETAIL_MAKE_DEFAULT_HPP
  8. namespace boost {
  9. namespace histogram {
  10. namespace detail {
  11. template <class T>
  12. T make_default_impl(const T& t, decltype(t.get_allocator(), 0)) {
  13. return T(t.get_allocator());
  14. }
  15. template <class T>
  16. T make_default_impl(const T&, float) {
  17. return T{};
  18. }
  19. template <class T>
  20. T make_default(const T& t) {
  21. return make_default_impl(t, 0);
  22. }
  23. } // namespace detail
  24. } // namespace histogram
  25. } // namespace boost
  26. #endif