25 #ifndef CRYPTO3_MAKE_UINT_T_HPP
26 #define CRYPTO3_MAKE_UINT_T_HPP
30 #include <boost/integer.hpp>
35 template<std::
size_t Size,
typename Integer>
36 static inline typename boost::uint_t<Size>::exact extract_uint_t(Integer v, std::size_t position) {
37 return static_cast<typename boost::uint_t<Size>::exact
>(v >>
38 (((~position) & (
sizeof(Integer) - 1)) << 3));
41 template<std::
size_t Size,
typename T>
42 static inline typename boost::uint_t<Size>::exact make_uint_t(
const std::initializer_list<T> &args) {
43 typedef typename std::initializer_list<T>::value_type value_type;
44 typename boost::uint_t<Size>::exact result = 0;
47 for (
const value_type &itr : args) {
48 result =
static_cast<typename boost::uint_t<Size>::exact
>(
49 (result << std::numeric_limits<value_type>::digits) | itr);
55 template<std::size_t Size,
typename... Args>
56 static inline typename boost::uint_t<Size>::exact make_uint_t(Args... args) {
57 return make_uint_t<Size,
typename std::tuple_element<0, std::tuple<Args...>>::type>({args...});