[Issue 20732] New: swap doesn't support types with impure gc or throwing copy constructors
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Apr 13 14:15:50 UTC 2020
    
    
  
https://issues.dlang.org/show_bug.cgi?id=20732
          Issue ID: 20732
           Summary: swap doesn't support types with impure gc or throwing
                    copy constructors
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com
struct S
{
   this(ref const S other) {}
}
void main()
{
   import std.alglorithm;
   S s;
   swap(s, s);
}
/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/mutation.d(2824): Error:
pure function std.algorithm.mutation.swap!(S).swap cannot call impure copy
constructor onlineapp.S.this
The offending line is here:
https://github.com/dlang/phobos/blob/c4f9c18ca788cf4bdb57344681f302d8f1309f36/std/algorithm/mutation.d#L2824
swap works around elaborate assignment but not elaborate construction.
--
    
    
More information about the Digitalmars-d-bugs
mailing list