Open vrqq opened 2 years ago
Hi. Thanks for filing this issue. It has since been addressed in the latest version: 1.x: https://godbolt.org/z/1Y53M5Knj 2.x: https://godbolt.org/z/exxafsKjx Is it possible for you to upgrade?
I am confusing that why can't be default_scale<(Digits < 0), (Radix != 2)>?
The specialisation that was provided in v1 is likely to be using a bit shift operation and so only works for the binary base.
Still in v1 since the C++17 we used. I try to add these code in cnl/_impl/num_traits/scale.h ( https://github.com/johnmcfarlane/cnl/blob/v1.x/include/cnl/_impl/num_traits/scale.h#L48 ) And then the problem solved.
namespace cnl {
template<int Digits, int Radix, template<typename, typename> class TNUM, typename S, typename Tag>
struct scale<Digits, Radix, TNUM<S, Tag>, _impl::enable_if_t<(
Digits<0 && cnl::_impl::is_integral<S>::value)>>
{
CNL_NODISCARD constexpr auto operator()(TNUM<S, Tag> const& s) const
-> decltype(s/_impl::power_value<S, -Digits, Radix>())
{
return s/_impl::power_value<S, -Digits, Radix>();
}
};
}
Could you please help me to review these code?
Hi. Thanks for the feedback and suggestion. I should be able to take a look at it later today.
The great thing about DVCS and CI is that you can safely break things without causing harm or disruption to others. So while I'm happy to help, you don't have to wait.
CI for v1.x is not currently working, likely due to updates to the docker images used to build the project. I'll need to fix the v1.x branch first.
After one years I retry to fix this issue, and there still some bug I cannot fixed. (I made a pull request into 991 branch it into branch)
The code previous I posted, was break the coding style of template partial specialization. For the third argument, I should keep it fixed on the special type, instead of using template<typename, typename>
to match any _impl::number type.
After reading the code in project, I found out the design-rule of struct scale
. The third argument class Rep
should be specialized in different files, such as _roudinginteger.h
So It may more suitable to move into https://github.com/johnmcfarlane/cnl/blob/991/include/cnl/rounding_integer.h#L74
There's some problem on test like std::hash<path>
in cppcon2017.cpp. In the code below, there still have problem on GCC and Clang compiler.
https://github.com/johnmcfarlane/cnl/blob/main/test/unit/presentations/cppcon2017.cpp#L23
And conan in pip has been updated into 2.0, but a lot of package hasn't upgraded in there repo.
When I try to use this code below, the complier error occurred when
std::cout
.Clang 12 with libstdc++ and c++ 17
Then I check the source code at: cnl/rounding_integer.h:63 I am confusing that why can't be
default_scale<(Digits < 0), (Radix != 2)>
? (tag v1.7, also v1.x branch currently)https://github.com/johnmcfarlane/cnl/blob/2dde6e62e608a4adc3c5504f067575efa4910568/include/cnl/rounding_integer.h#L57-L73