Bug 14098 – std.typecons.wrap should allow wrapping a struct

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-02-01T03:42:00Z
Last change time
2017-07-20T15:22:10Z
Keywords
pull
Assigned to
nobody
Creator
Jesse.K.Phillips+D

Comments

Comment #0 by Jesse.K.Phillips+D — 2015-02-01T03:42:30Z
The current implementation of wrap only allows for other classes to be wrapped into another interface. Structures are much more common in D so there is great value in supporting the ability to wrap a struct into a specified interface. This is similar to request #10404 but doesn't require a concrete type to be produced. For example: interface iRange { pure nothrow @nogc @property @safe int front(); void popFront(); pure nothrow @nogc @property @safe bool empty(); } void main() { import std.algorithm; import std.range; // Create a range type. auto squares = map!"a * a"(iota(10)); import std.typecons; // Wrap it in an interface. iRange squaresWrapped = squares.wrap!(iRange); }
Comment #1 by Jesse.K.Phillips+D — 2015-02-01T03:52:31Z
Comment #2 by razvan.nitu1305 — 2017-07-20T15:22:10Z
It looks like this have been merged. Closing