www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20732] New: swap doesn't support types with impure gc or


          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 puremagic.com
          Reporter: schveiguy 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:


swap works around elaborate assignment but not elaborate construction.

Apr 13 2020