-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Labels
Description
According to README.md:
- Signed and unsigned versions of
uintwide_tshould behave as closely as possible to the behaviors of signed and unsigned versions of built-inint.
So I tried to use math::wide_integer::uint256_t as a template parameter, but it failed with an error
'math::wide_integer::uintwide_t<256, unsigned int>' is not a valid type for a template non-type parameter because it is not structural
Fix:
This seems to be caused by the existence of non-public data members.
In math/wide_integer/uintwide_t.h I replaced all private: by public:, and now it works.
Code example:
#include <cstdint>
#include <iostream>
#include "wide-integer/uintwide_t.h"
template<typename UInt, uint32_t B = 8 * sizeof(UInt), UInt MAX = -UInt(1)> void f(uint32_t n) {
std::cout << B << "-bit ; MAX = " << MAX << ", n = " << UInt(n) << std::endl;
}
int main() {
f<math::wide_integer::uint256_t>(42); // prints "256-bit ; MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935, n = 42"
}
Apart from that, great work! sizeof(UInt) and -UInt(1) wouldn't even work with the types of Boost.Multiprecision, and UInt(-1) refused to be constexpr. All these things work fine with uintwide_t.