constexpr.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ///////////////////////////////////////////////////////////////
  2. // Copyright 2019 John Maddock. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  5. #ifndef BOOST_MP_CONSTEXPR_HPP
  6. #define BOOST_MP_CONSTEXPR_HPP
  7. #include <boost/config.hpp>
  8. namespace boost {
  9. namespace multiprecision {
  10. namespace std_constexpr {
  11. template <class T>
  12. inline BOOST_CXX14_CONSTEXPR void swap(T& a, T& b)
  13. {
  14. T t(a);
  15. a = b;
  16. b = t;
  17. }
  18. template <class InputIterator, class OutputIterator>
  19. inline BOOST_CXX14_CONSTEXPR OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result)
  20. {
  21. while (first != last)
  22. {
  23. *result = *first;
  24. ++first;
  25. ++result;
  26. }
  27. return result;
  28. }
  29. template <class I>
  30. inline BOOST_CXX14_CONSTEXPR bool equal(const I* first, const I* last, const I* other)
  31. {
  32. while (first != last)
  33. {
  34. if (*first != *other)
  35. return false;
  36. ++first;
  37. ++other;
  38. }
  39. return true;
  40. }
  41. }
  42. }
  43. } // namespace boost::multiprecision::std_constexpr
  44. #endif