Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
September 06, 2014 [Issue 13428] Add template to perform appropriate substitution for inout when it appears in a type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13428 Sobirari Muhomori <dfj1esp02@sneakemail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |http://forum.dlang.org/post | |/mailman.472.1409989340.578 | |3.digitalmars-d@puremagic.c | |om -- |
September 17, 2017 [Issue 13428] Add template to perform appropriate substitution for inout when it appears in a type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13428 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simen.kjaras@gmail.com --- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> --- import std.traits; template SubstituteInout(FromType, ToType) { static if (is(ToType == inout(SubType), SubType)) { alias SubstituteInout = CopyTypeQualifiers!(FromType, SubType); } else static if (is(ToType == SubType*, SubType)) { alias SubstituteInout = SubstituteInout!(FromType, SubType)*; } else static if (is(ToType == SubType[], SubType)) { alias SubstituteInout = SubstituteInout!(FromType, SubType)[]; } else static if (is(ToType == SubType[n], SubType, size_t n)) { alias SubstituteInout = SubstituteInout!(FromType, SubType)[n]; } else static if (is(ToType == SubType[KeyType], SubType, KeyType)) { alias SubstituteInout = SubstituteInout!(FromType, SubType)[SubstituteInout!(FromType, KeyType)]; } else { alias SubstituteInout = ToType; } } unittest { static assert(is(SubstituteInout!(const(string), int) == int)); static assert(is(SubstituteInout!(const(string), inout(int)[]) == const(int)[])); static assert(is(SubstituteInout!(const(string), inout(int)) == const(int))); static assert(is(SubstituteInout!(const(string), inout(int)*[][3][int]) == const(int)*[][3][int])); static assert(is(SubstituteInout!(const(string), inout(int)[inout(string)]) == const(int)[const(string)])); } -- |
March 23, 2018 [Issue 13428] Add template to perform appropriate substitution for inout when it appears in a type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13428 Manu <turkeyman@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |industry -- |
June 10, 2019 [Issue 13428] Add template to perform appropriate substitution for inout when it appears in a type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13428 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> --- @thewilsonator created dlang/phobos pull request #7062 "Fix issue 13428: add substituteInout" fixing this issue: - Fix issue 13428: add substituteInout https://github.com/dlang/phobos/pull/7062 -- |
August 16, 2019 [Issue 13428] Add template to perform appropriate substitution for inout when it appears in a type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13428 --- Comment #3 from Simen Kjaeraas <simen.kjaras@gmail.com> --- I revisited this today, and realized it does not handle mixed qualifiers, like inout(const(int)*). As this is a rather big oversight, here's an improved implementation: template SubstituteInout(FromType, ToType) { alias Modifiers(T) = CopyTypeQualifiers!(FromType, T); alias Next(T) = SubstituteInout!(FromType, T); static if (is(ToType U == immutable U)) alias SubstituteInout = immutable Next!U; else static if (is(ToType U == shared inout const U)) alias SubstituteInout = shared const Modifiers!(Next!U); else static if (is(ToType U == shared inout U)) alias SubstituteInout = shared Modifiers!(Next!U); else static if (is(ToType U == shared const U)) alias SubstituteInout = shared const Next!U; else static if (is(ToType U == shared U)) alias SubstituteInout = shared Next!U; else static if (is(ToType U == inout const U)) alias SubstituteInout = const Modifiers!(Next!U); else static if (is(ToType U == inout U)) alias SubstituteInout = Modifiers!(Next!U); else static if (is(ToType U == const U)) alias SubstituteInout = const Next!U; else static if (is(ToType U == U* )) alias SubstituteInout = Next!U*; else static if (is(ToType U == U[] )) alias SubstituteInout = Next!U[]; else static if (is(ToType U == U[N], size_t N)) alias SubstituteInout = Next!U[N]; else static if (is(ToType U == U[K], K)) alias SubstituteInout = Next!U[Next!K]; else alias SubstituteInout = ToType; } unittest { static assert(is(SubstituteInout!(const(string), int) == int)); static assert(is(SubstituteInout!(const(string), inout(int)[]) == const(int)[])); static assert(is(SubstituteInout!(const(string), inout(int)) == const(int))); static assert(is(SubstituteInout!(const(string), inout(int)*[][3][int]) == const(int)*[][3][int])); static assert(is(SubstituteInout!(const(string), inout(int)[inout(string)]) == const(int)[const(string)])); static assert(is(SubstituteInout!(const(int), inout(const(int)*)) == const(int*))); static assert(is(SubstituteInout!(int, inout(const(int)*)) == const(int)*)); } -- |
December 17, 2022 [Issue 13428] Add template to perform appropriate substitution for inout when it appears in a type | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13428 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P4 -- |
Copyright © 1999-2021 by the D Language Foundation