www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Problem with Variant

reply "develop32" <develop32 gmail.com> writes:
void main()
{
	struct Vector
	{
		float length();
	}

	import std.variant;
	Variant v = Vector();
}

Currently this does not work, as it seems Variant thinks length() 
is a property restricted to arrays.

"cannot implicitly convert expression ((*zis).length()) of type 
float to int	C:\D\dmd2\src\phobos\std\variant.d	488"

I quickly changed that line in variant.do to "static if 
(is(typeof(zis.length)) && is(ReturnType!(zis.length) == 
size_t))" and my code compiles.

Currently its a hack, but should it be more developed and would 
it not interfere with something else?
Jun 28 2013
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 6/28/13 4:27 PM, develop32 wrote:
 void main()
 {
 struct Vector
 {
 float length();
 }

 import std.variant;
 Variant v = Vector();
 }

 Currently this does not work, as it seems Variant thinks length() is a
 property restricted to arrays.

 "cannot implicitly convert expression ((*zis).length()) of type float to
 int C:\D\dmd2\src\phobos\std\variant.d 488"

 I quickly changed that line in variant.do to "static if
 (is(typeof(zis.length)) && is(ReturnType!(zis.length) == size_t))" and
 my code compiles.

 Currently its a hack, but should it be more developed and would it not
 interfere with something else?
Could you please paste your note into a bug report? In a perfect world you may want to also submit a pull request! Thanks, Andrei
Jun 28 2013
next sibling parent "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Friday, June 28, 2013 17:14:22 Andrei Alexandrescu wrote:
 Could you please paste your note into a bug report? In a perfect world
 you may want to also submit a pull request!
Well, he can do that in an _imperfect_ world too... ;) - Jonathan M Davis
Jun 28 2013
prev sibling parent "develop32" <develop32 gmail.com> writes:
On Saturday, 29 June 2013 at 00:14:19 UTC, Andrei Alexandrescu 
wrote:
 Could you please paste your note into a bug report? In a 
 perfect world you may want to also submit a pull request!
Filled a bug http://d.puremagic.com/issues/show_bug.cgi?id=10500 And I'll try to make world a better place too...
Jun 29 2013