replace_type.hpp 818 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 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_REPLACE_TYPE_HPP
  7. #define BOOST_HISTOGRAM_DETAIL_REPLACE_TYPE_HPP
  8. #include <boost/core/use_default.hpp>
  9. #include <string>
  10. #include <type_traits>
  11. namespace boost {
  12. namespace histogram {
  13. namespace detail {
  14. template <class T, class From, class To>
  15. using replace_type = std::conditional_t<std::is_same<T, From>::value, To, T>;
  16. template <class T, class Default>
  17. using replace_default = replace_type<T, boost::use_default, Default>;
  18. template <class T>
  19. using replace_cstring = replace_type<T, const char*, std::string>;
  20. } // namespace detail
  21. } // namespace histogram
  22. } // namespace boost
  23. #endif