digitalmars.D.bugs - [Issue 3508] New: hasLength is broken for length defined as function
- d-bugmail puremagic.com (46/46) Nov 14 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3508
- d-bugmail puremagic.com (10/17) Nov 14 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3508
- d-bugmail puremagic.com (12/12) May 02 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3508
http://d.puremagic.com/issues/show_bug.cgi?id=3508
Summary: hasLength is broken for length defined as function
Product: D
Version: 2.036
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody puremagic.com
ReportedBy: k-foley onu.edu
import std.stdio;
struct Test1 { ulong length(); }
struct Test2 { ulong length; }
struct Test3 { string length; }
/* Definition from std.range
template hasLength(R)
{
enum bool hasLength = is(typeof(R.init.length) : ulong);
}
*/
template hasLength(R)
{
enum bool hasLength = is(typeof({
auto r = R.init;
auto l = r.length;
static assert( is(typeof(l) : ulong) );
}()));
}
int main(string[] args)
{
writeln( std.range.hasLength!(Test1) ); // false
writeln( std.range.hasLength!(Test2) ); // true
writeln( std.range.hasLength!(Test3) ); // false
writeln( test.hasLength!(Test1) ); // true
writeln( test.hasLength!(Test2) ); // true
writeln( test.hasLength!(Test3) ); // false
return 0;
}
---
I included my proposed fix as test.hasLength.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 14 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3508
import std.stdio;
struct Test1 { ulong length(); }
struct Test2 { ulong length; }
struct Test3 { string length; }
...
I accidentally left out a few lines at the top (can't edit my original post):
---
module test;
import std.range;
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 14 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3508
Masahiro Nakagawa <repeatedly gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |repeatedly gmail.com
Resolution| |DUPLICATE
10:04:17 PDT ---
*** This issue has been marked as a duplicate of issue 2873 ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02 2010









d-bugmail puremagic.com 