www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24285] New: Cannot swap a std.typecons.Tuple

https://issues.dlang.org/show_bug.cgi?id=24285

          Issue ID: 24285
           Summary: Cannot swap a std.typecons.Tuple
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: nick geany.org

enum x = (){
    import std.algorithm, std.typecons;
    Tuple!int a, b;
    swap(a, b);
    return 0;
}();

/usr/include/dmd/phobos/std/algorithm/mutation.d(2836): Error: reinterpreting
cast from `Tuple!int*` to `ubyte*` is not supported in CTFE

First reported here:
https://issues.dlang.org/show_bug.cgi?id=21429#c2

This also applies for any struct T that satisfies isBlitAssignable yet
`hasElaborateAssign!T || !isAssignable!T` is true.

PR incoming.

--
Dec 18 2023