2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2014-01-08 07:48:12 +00:00
|
|
|
Copyright (c) 2011-2014 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2012-08-08 12:59:47 +00:00
|
|
|
#ifndef SPROUT_BIT_ROTATE_HPP
|
|
|
|
#define SPROUT_BIT_ROTATE_HPP
|
|
|
|
|
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/config.hpp>
|
2014-03-31 05:58:24 +00:00
|
|
|
#include <sprout/bit/rotl.hpp>
|
|
|
|
#include <sprout/bit/rotr.hpp>
|
2012-08-08 12:59:47 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
//
|
|
|
|
// left_rotate
|
|
|
|
//
|
2014-03-31 05:58:24 +00:00
|
|
|
template<typename Integral>
|
2012-12-17 11:10:17 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2014-03-31 05:58:24 +00:00
|
|
|
std::is_integral<Integral>::value,
|
|
|
|
Integral
|
2012-12-17 11:10:17 +00:00
|
|
|
>::type
|
2014-03-31 05:58:24 +00:00
|
|
|
left_rotate(Integral x, int s) {
|
|
|
|
return sprout::rotl(x, s);
|
2012-08-08 12:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// right_rotate
|
|
|
|
//
|
2014-03-31 05:58:24 +00:00
|
|
|
template<typename Integral>
|
2012-12-17 11:10:17 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
2014-03-31 05:58:24 +00:00
|
|
|
std::is_integral<Integral>::value,
|
|
|
|
Integral
|
2012-12-17 11:10:17 +00:00
|
|
|
>::type
|
2014-03-31 05:58:24 +00:00
|
|
|
right_rotate(Integral x, int s) {
|
|
|
|
return sprout::rotr(x, s);
|
2012-08-08 12:59:47 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
2013-03-22 05:24:19 +00:00
|
|
|
#endif // #ifndef SPROUT_BIT_ROTATE_HPP
|