On Wednesday, 3 May 2017 at 17:54:13 UTC, H. S. Teoh wrote:
On Wed, May 03, 2017 at 05:26:27PM +, Nothing via
Digitalmars-d-learn wrote:
Hi, Honestly I am new to D and templates system so excuse me
But of course, if you wish to write your own Box type, then to
answer your question:
[...]
On Wed, May 03, 2017 at 08:24:31PM +0200, ag0aep6g via Digitalmars-d-learn
wrote:
> On 05/03/2017 08:04 PM, H. S. Teoh via Digitalmars-d-learn wrote:
> > You only need a common interface if you wish to do something more
> > with Box!X instantiations that's common across all Boxes.
>
> The goal
On 05/03/2017 08:04 PM, H. S. Teoh via Digitalmars-d-learn wrote:
You only need a common interface if you wish to do something more with
Box!X instantiations that's common across all Boxes.
The goal is to return `true` for two empty boxes with different payload
types. From the OP: "Empty
On Wed, May 03, 2017 at 08:04:20PM +0200, ag0aep6g via Digitalmars-d-learn
wrote:
> On 05/03/2017 07:26 PM, Nothing wrote:
[...]
> > So is there an idiomatic approach to know if the Object is an
> > instance of Box (regardless of content type T) and than if necessary
> > to know exactly if two
On 05/03/2017 07:26 PM, Nothing wrote:
Equality checking is where I stuck. It should work as follows:
0. If we compare the Box [b]b[/b] to an object [b]o[/b] that is not an
instance of Box, it should return false.
1. Empty boxes are equal no matter the type.
2. If type of payload for two boxes
On Wed, May 03, 2017 at 05:26:27PM +, Nothing via Digitalmars-d-learn wrote:
> Hi, Honestly I am new to D and templates system so excuse me if my
> question will seem trivial.
>
> I want to develop a generic Box(T) class that can be either empty or
> hold a value of arbitrary type T.
Have a
Hi, Honestly I am new to D and templates system so excuse me if
my question will seem trivial.
I want to develop a generic Box(T) class that can be either empty
or hold a value of arbitrary type T.
//
class Box(T)
{
override bool opEquals(Object o)
{
//...