New to D and mimicking C++ : how to implement std::integral_constant<>?
Picaud Vincent via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Nov 7 15:17:26 PST 2016
On Monday, 7 November 2016 at 23:07:27 UTC, Picaud Vincent wrote:
> typo...
> auto capacity = max(0,(size_-1)*stride_+1);
To be more correct I have something like:
alias IntergralConstant!(int,0) Zero_c;
alias IntergralConstant!(int,1) One_c;
auto capacity = max(Zero_c,(size_-One_c)*stride_+One_c);
with "smooth" implicit conversion IntegralConstant -> int for
cases where size_ or stride_ are "int" and not both
IntegralConstant types.
More information about the Digitalmars-d-learn
mailing list