Matthias Walter wrote:
Can I handle this in another way (like making the template a conditional
one)?
Template constraints[1] sounds like what you want.
Basically, you want the following:
== Module a ==
| module a;
|
| template Base (T) if (!is(T t : t*))
| {
| alias T Base;
| }
== Modul
Hi list,
I tried to write a traits class comparable to iterator_traits in C++ STL
or graph_traits in Boost Graph Library in D 2.0, but failed to do so via
template specialization which is put into different modules. Putting
everything into one module interferes with extensibility. I tried the
foll
Hello Jacob,
That's annoying, specially since "char" is a value type. I would
preferably have a solution for both D1 and D2. Can I use a template to
cast/alias away the immutable part?
One solution would be to have templates strip off const/immutable from the
top level of args.
void F1(T)(T
On 2010-06-27 19:26, Simen kjaeraas wrote:
Jacob Carlborg wrote:
Why doesn't the following code work in D2 (it works in D1)?
void foo (T) (in T[] a, T b)
{
}
void main ()
{
"asd".foo('s');
}
The error I get is:
main.d(10): Error: template main.foo(T) does not match any function
template d
Simen kjaeraas:
> void foo(T,U)(const T[] a, U b) if (is(Unqual!T == Unqual!U)) {
> ...
> }
Yes, this was my solution.
My first solution was:
import std.traits: Unqual;
void foo(T)(T[] a, Unqual!T b) {}
void main () {
"asd".foo('s');
}
But it doesn't work, and I don't know if it's supposed t
Jacob Carlborg wrote:
Why doesn't the following code work in D2 (it works in D1)?
void foo (T) (in T[] a, T b)
{
}
void main ()
{
"asd".foo('s');
}
The error I get is:
main.d(10): Error: template main.foo(T) does not match any function
template declaration
main.d(10): Err
On 06/27/2010 12:18 PM, Jacob Carlborg wrote:
Why doesn't the following code work in D2 (it works in D1)?
void foo (T) (in T[] a, T b)
{
}
void main ()
{
"asd".foo('s');
}
"asd".foo(cast(immutable) 's');
Why doesn't the following code work in D2 (it works in D1)?
void foo (T) (in T[] a, T b)
{
}
void main ()
{
"asd".foo('s');
}
The error I get is:
main.d(10): Error: template main.foo(T) does not match any function
template declaration
main.d(10): Error: template main.foo(T) c
Pierre Rouleau:
> In what sense?
This is valid D1 code:
import std.stdio;
void main() {
string s = "this is
just
a
test";
writefln(s);
}
Bye,
bearophile
On 27/06/10 11:36 AM, bearophile wrote:
But keep in mind that normal D string literals can span more than one line :-)
In what sense? In the sense that adjacent strings are concatenated? If I
want to create a string literal that embeds new line without explicitly
placing a '\n' inside the st
Jonathan M Davis:
> Okay. The functions in std.algorithm are quite powerful, but sometimes you
> have
> to play around with them a bit to figure out how to do exactly what you're
> trying
> to do.
Some of them need to be improved in their concept and API. Some of them are
awkward to use or t
Philippe Sigaud:
> I couldn't find a bugzilla entry for this and I cannot believe no one ever
> tried to put an auto fun inside main!
Maybe auto funcs are seen as instantiated templates, and templates can't be
defined inside functions. Anyway, I think you can file this as enhancement
request.
B
Pierre Rouleau:
> I was wondering if D had the equivalnt of Python's triple quote string
> literals and it does: the delimited string serves the same purpose. Great!
But keep in mind that normal D string literals can span more than one line :-)
Bye,
bearophile
Is it defined somewhere that auto functions are not authorized inside main?
void main()
{
auto fun(string s) { return s;} // this does not compile
}
error:
main.d|6|found 's' when expecting ')'|
main.d|6|semicolon expected, not ')'|
main.d|6|found ')' instead of statement|
main.d|7|unrecogni
On 27/06/10 9:52 AM, Simen kjaeraas wrote:
Pierre Rouleau wrote:
Hi all,
The D2.0 lexical page describes delimited string and token string
literals. Is there any example of how these are used and why, somewhere?
Token strings are added for the specific use case of string mixins[1].
They mus
On 27/06/10 9:52 AM, Simen kjaeraas wrote:
Pierre Rouleau wrote:
Hi all,
The D2.0 lexical page describes delimited string and token string
literals. Is there any example of how these are used and why, somewhere?
Token strings are added for the specific use case of string mixins[1].
They mus
On Sun, Jun 27, 2010 at 10:11, Simen kjaeraas wrote:
> auto fn1 = ( string s ) {
>return s;
> };
>
> auto fn2 = ( string s ) {
>return map!fn1( [""] );
> };
>
> auto idirs = map!fn2( [""] );
>
> The above code gives the following errors:
> foo.d(114): Error: struct foo.main.Map!(fn
Pierre Rouleau wrote:
Hi all,
The D2.0 lexical page describes delimited string and token string
literals. Is there any example of how these are used and why, somewhere?
Token strings are added for the specific use case of string mixins[1].
They must contain valid D code.
mixin( q{ a = b;
Hi all,
The D2.0 lexical page describes delimited string and token string
literals. Is there any example of how these are used and why, somewhere?
Thanks
-- Pierre
auto fn1 = ( string s ) {
return s;
};
auto fn2 = ( string s ) {
return map!fn1( [""] );
};
auto idirs = map!fn2( [""] );
The above code gives the following errors:
foo.d(114): Error: struct foo.main.Map!(fn2,string[]).Map inner struct
Map cannot be a field
foo.d(114): Error: st
On Sun, Jun 27, 2010 at 08:07, BCS wrote:
> Hello Jonathan,
>
>
> For example, there are two functions that I'd like to be have: all()
>> and any(). That is, I want a function which checks a predicate against
>> a range and returns whether all elements in that range satisfy the
>> predicate, and
21 matches
Mail list logo