1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

add c++1y rightmost bit manipurations

This commit is contained in:
bolero-MURAKAMI 2014-03-31 17:18:22 +09:00
parent 56c9d52436
commit e244ea2932
21 changed files with 560 additions and 183 deletions

28
sprout/bit/maskt0ls1b.hpp Normal file
View file

@ -0,0 +1,28 @@
/*=============================================================================
Copyright (c) 2011-2014 Bolero MURAKAMI
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)
=============================================================================*/
#ifndef SPROUT_BIT_MASKT0LS1B_HPP
#define SPROUT_BIT_MASKT0LS1B_HPP
#include <type_traits>
#include <sprout/config.hpp>
namespace sprout {
//
// maskt0ls1b
//
template<typename Integral>
inline SPROUT_CONSTEXPR typename std::enable_if<
std::is_integral<Integral>::value,
Integral
>::type
maskt0ls1b(Integral x) SPROUT_NOEXCEPT {
return (x - 1) ^ x;
}
} // namespace sprout
#endif // #ifndef SPROUT_BIT_MASKT0LS1B_HPP