I am "trying" to write a function that takes an array of items,
and returns the length of longest item.
[code]
size_t maxLength(A)( const A[] listOfString ) if( __traits(
hasMember, A, "length" ) )
{
return 0; // not implemented yet
}
[/code]
I tried it with
if( __traits( compiles,
On Thursday, 8 October 2015 at 09:29:30 UTC, tcak wrote:
I am "trying" to write a function that takes an array of items,
and returns the length of longest item.
[code]
size_t maxLength(A)( const A[] listOfString ) if( __traits(
hasMember, A, "length" ) )
{
return 0; // not
On 10/08/15 11:29, tcak via Digitalmars-d-learn wrote:
> I am "trying" to write a function that takes an array of items, and returns
> the length of longest item.
>
> [code]
> size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A,
> "length" ) )
> {
> return 0; // not
On Thursday, 8 October 2015 at 09:29:30 UTC, tcak wrote:
I am "trying" to write a function that takes an array of items,
and returns the length of longest item.
[code]
size_t maxLength(A)( const A[] listOfString ) if( __traits(
hasMember, A, "length" ) )
{
return 0; // not
On Thursday, 8 October 2015 at 09:50:12 UTC, John Colvin wrote:
On Thursday, 8 October 2015 at 09:29:30 UTC, tcak wrote:
[...]
I'm 99% sure something like __traits(hasMember, int[], "length"
) should evaluate to true. Please file a bug at
issues.dlang.org I notice it also doesn't work for
On Thursday, 8 October 2015 at 15:22:02 UTC, tcak wrote:
BTW, there is nothing like std.traits.hasLength.
yeah, that's because __traits(hasMember, ...) should be good
enough, but obviously not in this case at the moment.
On Thursday, 8 October 2015 at 15:22:02 UTC, tcak wrote:
BTW, there is nothing like std.traits.hasLength.
You're just looking in the wrong place =)
http://dlang.org/phobos/std_range_primitives.html#hasLength