digitalmars.D.bugs - [Issue 8165] New: BigInt opAssign return value
- d-bugmail puremagic.com (62/62) May 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8165
- d-bugmail puremagic.com (6/6) Jul 16 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8165
- d-bugmail puremagic.com (12/12) Jul 16 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8165
http://d.puremagic.com/issues/show_bug.cgi?id=8165
Summary: BigInt opAssign return value
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc
This code is allowed, it's handy when you have to initialize two array items:
void main() {
int[2] a;
a[0] = a[1] = 1;
}
So I'd like to do:
import std.bigint: BigInt;
void main() {
BigInt[2] a;
a[0] = 1; // OK
a[0] = a[1] = 1; // error
}
DMD 2.060alpha gives:
test.d(5): Error: template std.bigint.BigInt.opAssign does not match any
function template declaration
...\dmd2\src\phobos\std\bigint.d(115): Error: template
std.bigint.BigInt.opAssign cannot deduce template function from argument types
!()(void)
I think to solve this problem it's enough to modify the two functions:
///
void opAssign(T: long)(T x)
{
data = cast(ulong)((x < 0) ? -x : x);
sign = (x < 0);
}
///
void opAssign(T:BigInt)(T x)
{
data = x.data;
sign = x.sign;
}
Like this:
///
BigInt opAssign(T: long)(T x)
{
data = cast(ulong)((x < 0) ? -x : x);
sign = (x < 0);
return this;
}
///
BigInt opAssign(T:BigInt)(T x)
{
data = x.data;
sign = x.sign;
return x;
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 30 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8165 *** Issue 7080 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 16 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8165
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |clugdbug yahoo.com.au
Resolution| |FIXED
https://github.com/D-Programming-Language/phobos/commit/2ab19e80a96f1e9e6876a5699032945365e5d51b
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 16 2012









d-bugmail puremagic.com 