Fun with templates

Dmitry Olshansky dmitry.olsh at gmail.com
Sat Jul 6 14:04:52 PDT 2013


06-Jul-2013 22:54, TommiT пишет:
> On Saturday, 6 July 2013 at 18:07:08 UTC, Dicebot wrote:
>> On Saturday, 6 July 2013 at 15:38:45 UTC, Artur Skawina wrote:
>>> Do you think this would be a problem /in practice/?
>>
>> Yes. Honestly, lot of problems. I can easily imagine template function
>> that modifies its argument in-place for a mutable qualifier and
>> allocates a copy for an immutable one. Templates that introspect their
>> parameter type to format some string. Different algorithms for
>> processing mutable and immutable versions of same container.
>
> He's talking about changing the semantics only on POD types, like int,
> struct of ints, static array of ints... only types that can implicitly
> convert from immutable to mutable.
>

I've seen an aggressive proposal back in the day to just do a shallow 
unqual on all aggregates passed by value.

>> And it is not just code breakage - you propose some magic instead of
>> simple well-defined semantics and so far I don't even see the detailed
>> description how new system should behave.
>
> As I understand it, it would be like what C++ does, but only for POD
> types. Just take const, immutable, whatever away when they're passed by
> value.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list