On Friday, 6 May 2022 at 05:44:39 UTC, vit wrote:
Try this:
Very Good,Thank you very much!
On Friday, 6 May 2022 at 00:41:18 UTC, zjh wrote:
Hello everyone,I have following function:
```d
import core.stdc.stdio;
void f(int i,int j){
printf("%i,%i",i,j);
}
```
I want to forward `int[N]` to `(int i,int j)` etc. How can I
write a forwarding function?
```d
void ff(alias
Hello everyone,I have following function:
```d
import core.stdc.stdio;
void f(int i,int j){
printf("%i,%i",i,j);
}
```
I want to forward `int[N]` to `(int i,int j)` etc. How can I
write a forwarding function?
```d
void ff(alias g,int...I)(int[2]k){
g(k[I]);
}//How to unpack template
On Friday, 22 April 2022 at 08:04:16 UTC, JG wrote:
On Thursday, 21 April 2022 at 21:02:47 UTC, JG wrote:
Hi,
Could someone possibly help me to understand why the commented
line doesn't compile?
Good job, works great! Potential is high:
```d
void main()
{
alias type = real;
auto
On 4/22/22 01:04, JG wrote:
> In response to the change to "alias", which has several upsides
> including faster code. I would note it also has some downsides including
> every lambda produces a new type so that (at the moment) the following
> assert
> holds:
I got confused a little bit there.
On Thursday, 21 April 2022 at 21:02:47 UTC, JG wrote:
Hi,
Could someone possibly help me to understand why the commented
line doesn't compile?
```d
import std;
struct MapResult(R,F)
{
R r;
const F f;
auto empty() { return r.empty; }
auto front() { return f(r.front); }
On Thu, Apr 21, 2022 at 09:02:47PM +, JG via Digitalmars-d-learn wrote:
> Hi,
>
> Could someone possibly help me to understand why the commented line
> doesn't compile?
>
>
> ```d
> import std;
>
> struct MapResult(R,F)
> {
> R r;
> const F f;
> auto empty() { return r.empty; }
On Thursday, 21 April 2022 at 21:38:14 UTC, Ali Çehreli wrote:
```d
auto myMap(alias f, R)(R r) {
pragma(msg, typeof(f));
return MapResult!(R, f)(r);
}
```
It looks delicious when the convenience function works magic with
Voldemort:
```d
import std.range, std.stdio;
auto myMap(alias
On Thursday, 21 April 2022 at 21:02:47 UTC, JG wrote:
Hi,
Could someone possibly help me to understand why the commented
line doesn't compile?
```d
import std;
struct MapResult(R,F)
{
R r;
const F f;
auto empty() { return r.empty; }
auto front() { return f(r.front); }
t represents the
types of function templates.
One way of changing the code is to use the following but it does not
really fit because of course you may want types other than 'int':
(int x) => 2 * x // Now the type is known
The more logical thing to do is to stay with alias temp
Hi,
Could someone possibly help me to understand why the commented
line doesn't compile?
```d
import std;
struct MapResult(R,F)
{
R r;
const F f;
auto empty() { return r.empty; }
auto front() { return f(r.front); }
void popFront() { r.popFront; }
auto save() { return
change:
{ rl.remove(i);
to:
{ rl = rl.remove(i);
--
Javascript is what you use to allow third party programs you don't know
anything about and doing you know not what to run on your computer.
On Thu, Sep 02, 2021 at 02:28:23PM -0700, Charles Hixson via
Digitalmars-d-learn wrote:
[...]
> --
> Javascript is what you use to allow third part programs you don't know
> anything about and doing you know not what to run on your computer.
ROFL! I'm st^Wborrowing this for my quotes file. ;-)
T
/** An Associative Array with some Randomization and Linear features.
* Note: This is done in a simplified and not too generalized fashion
so that I don't need to
* figure out template parameters at the moment. It should be
redone later, when my mastery
* is better. Th
On 8/29/21 3:31 PM, Charles Hixson wrote:
> Thanks. I going to have to study:
>
> enum supportsCall = isIntegral!(typeof(T.init.%s()));
>
>
> for awhile to make any sense of that, but it looks like just what I was
> looking for.
Trying to explain with comments:
// This is an eponymous template
Thanks. I going to have to study:
enum supportsCall = isIntegral!(typeof(T.init.%s()));
for awhile to make any sense of that, but it looks like just what I was
looking for.
On 8/29/21 2:41 PM, Ali Çehreli via Digitalmars-d-learn wrote:
On 8/29/21 11:32 AM, Charles H. wrote:
I've set up
On 8/29/21 11:32 AM, Charles H. wrote:
I've set up a class template (so far untested) thus:
class AARL (T, ndx = "ndx")
if (isIntegral(T.init.ndx) )
If I'm correct, this should work for ndx an integer variable of T,
but I'd really like T to be able to be anything
I've set up a class template (so far untested) thus:
class AARL (T, ndx = "ndx")
if (isIntegral(T.init.ndx) )
If I'm correct, this should work for ndx an integer variable of T, but
I'd really like T to be able to be anything which can be stored both in
an array and in an associative
I've set up a class template (so far untested) thus:
classAARL (T, ndx = "ndx")
if (isIntegral(T.init.ndx) )
If I'm correct, this should work for ndx an integer variable
of T, but I'd really like T to be able to be anything which can
be stored both in an array and in
" way from the outside the get the names of
the template values?
As far as I'm aware there is no way to introspect on template
parameters at all.
Let's say i instantiate the template does that change anything?
Can I get the "placeholder" names in any way then?
I don't think inst
ate values?
As far as I'm aware there is no way to introspect on template
parameters at all.
Let's say i instantiate the template does that change anything?
Can I get the "placeholder" names in any way then?
On Tuesday, 27 July 2021 at 08:15:12 UTC, Lukas Borin wrote:
Consider the following template
```D
auto foo(T, int W, int H)(T p1, T p2) { }
```
Is there a "nice" way from the outside the get the names of the
template values?
As far as I'm aware there is no way to introspect o
Consider the following template
```D
auto foo(T, int W, int H)(T p1, T p2) { }
```
Is there a "nice" way from the outside the get the names of the
template values?
E.g:
```D
pragma(msg, TemplateParameterNames!(foo)); // AliasSeq!("T", "W",
"H") or ["T", "W", "H"]
```
I know you can find
On Sunday, 20 December 2020 at 13:58:00 UTC, Max Haughton wrote:
The if is a template constraint.
Ah sorry! I must have missed that part of the dlang tour.
(https://tour.dlang.org/tour/en/gems/template-meta-programming)
Thanks a lot!
On Sunday, 20 December 2020 at 13:51:08 UTC, Rekel wrote:
I found a lot of the Phobos documentation to contain template
arguments and if statements that made no sense to me, for
example:
```
uint readf(alias format, A...) (
auto ref A args
)
if (isSomeString!(typeof(format)));
uint
I found a lot of the Phobos documentation to contain template
arguments and if statements that made no sense to me, for example:
```
uint readf(alias format, A...) (
auto ref A args
)
if (isSomeString!(typeof(format)));
uint readf(A...) (
scope const(char)[] format,
auto ref A args
);
```
On Sunday, 29 November 2020 at 21:52:10 UTC, JN wrote:
ValueHolder v2; // error
Make it `ValueHolder!()` and it works.
Default template params are only considered *after* it is clear a
template needs to be instantiated. `ValueHolder` by itself is
just the name of the template which is
class ValueHolder(T = int)
{
T t;
}
void main()
{
ValueHolder!int v1;
ValueHolder v2; // error
}
onlineapp.d(9): Error: template class onlineapp.ValueHolder(T =
int) is used as a type without instantiation; to instantiate it
use ValueHolder!(arguments)
On Wednesday, 28 October 2020 at 05:51:14 UTC, Nicholas Wilson
wrote:
but for a templated C this is tricker as I can't use a template
sequence parameter (...) unless C uses it in the same position
(I'm trying to generate a mangle from it so it needs to be
exact). Given
class
reflection
}
alias ScopeClass = Anon!(int, 0, float);
}
So I'm not sure you can do what you want to do - D doesn't have
any way to reflect on template parameters (though you CAN extract
arguments I don't think it really helps here since you can't tell
if the arguments were from `int, float
Given
template ScopeClass(C)
{
//...
}
where C is a, possibly templated, class I want the eponymous
member of ScopeClass!(C) to have the same templatedness (both
parameters and arguments)as C.
For a non-template C this is a simple as:
template ScopeClass(C)
{
class ScopeClass
{
And what about:
void test() {}
and
void text(alias qqq)() {}
?
On Sunday, 11 October 2020 at 06:53:59 UTC, Andrey wrote:
Hello,
How to count a number of parameters in uninitialized template
method?
For example:
struct Test
{
void abc(int a, bool status, string text)() {}
{
The method "Test.abc" has three template paramenters.
I know that
Hello,
How to count a number of parameters in uninitialized template
method?
For example:
struct Test
{
void abc(int a, bool status, string text)() {}
{
The method "Test.abc" has three template paramenters.
I know that "TemplateArgsOf" exists but it is used only for
INITIALIZED
Given the code:
```
auto foo(alias A, string str)()
{
// do stuff
}
struct Bar
{
// members
}
Bar bar;
bar.foo!"hello"; // This is an error. Would have to do foo!(bar,
"hello")
```
Assuming that I haven't misunderstood or borked something, having
UFCS for function templates whose
On Tuesday, 11 June 2019 at 13:22:26 UTC, Adam D. Ruppe wrote:
On Tuesday, 11 June 2019 at 09:26:56 UTC, realhet wrote:
static bool processId(bool captureIntId, alias r, alias a)(){
mixin("alias ta = typeof("~a.stringof~");");
As I have been saying a lot, mixin and stringof should
On Tuesday, 11 June 2019 at 09:26:56 UTC, realhet wrote:
static bool processId(bool captureIntId, alias r, alias a)(){
mixin("alias ta = typeof("~a.stringof~");");
As I have been saying a lot, mixin and stringof should almost
never be used together. You could write this a lot easier:
Hi again,
I'm trying to do variadic parameter processing, and I have the
following function that works fine:
static bool same(T1, T2)(){
pragma(msg, "same? "~T1.stringof~" "~T2.stringof);
return is(immutable(T1)==immutable(T2));
}
Btn btn(T...)(string params, T args){
enum
On Friday, 11 January 2019 at 06:13:11 UTC, Paul Backus wrote:
On Friday, 11 January 2019 at 04:59:50 UTC, Yui Hosaka wrote:
I want to do something like this:
template S(T) {
}
void main() {
pragma(msg, S!(int).T); // Error: no property `T` for type
`void`
}
You can get the
On Friday, 11 January 2019 at 04:59:50 UTC, Yui Hosaka wrote:
I want to do something like this:
template S(T) {
}
void main() {
pragma(msg, S!(int).T); // Error: no property `T` for type
`void`
}
You can get the arguments of a template instance as an AliasSeq
using
I want to do something like this:
template S(T) {
}
void main() {
pragma(msg, S!(int).T); // Error: no property `T` for type
`void`
}
Using alias, it is possible to get T by another name:
template S(T) {
alias t = T;
}
void main() {
pragma(msg, S!(int).t);
}
But
On Wednesday, 25 April 2018 at 11:26:40 UTC, Vijay Nayar wrote:
On Wednesday, 25 April 2018 at 10:25:11 UTC, Simen Kjærås wrote:
In the general case, the issue is unsolvable, since the
relationship between template parameters and alias results may
be arbitrarily complex. A simple degenerate
On 04/25/2018 12:25 PM, Simen Kjærås wrote:
It's a known issue, and could be solved in some cases by partial
template expansion, which is currently not part of the language. I
believe it's in bugzilla somewhere, but a cursory search yielded no
results.
On Wednesday, 25 April 2018 at 10:25:11 UTC, Simen Kjærås wrote:
In the general case, the issue is unsolvable, since the
relationship between template parameters and alias results may
be arbitrarily complex. A simple degenerate case is this:
Ok, wow, you weren't kidding. That becomes really
no results.
In the general case, the issue is unsolvable, since the
relationship between template parameters and alias results may be
arbitrarily complex. A simple degenerate case is this:
alias Foo(T) = string;
T fun(T)(Foo!T a) { return T.init; }
unittest {
// What's val's type?
auto
On Wednesday, 25 April 2018 at 07:39:28 UTC, Vijay Nayar wrote:
addAllWithAlias(v1); // Error!
One more note, this following line works correctly.
addAllWithAlias!double(v1); // OK.
encountered a bug or
missing feature?
Example below:
```
/**
* Demonstrate an unexpected compiler error when using implicit
template parameters
* combined with aliases to partially instantiate templates.
*/
struct Vector(ElemT, size_t SizeV) {
private:
ElemT[SizeV] _data;
public:
@property
On Sunday, 5 February 2017 at 21:51:14 UTC, Meta wrote:
On Sunday, 5 February 2017 at 20:36:57 UTC, Mark Fisher wrote:
I want to write a template:
static auto ref BindArg(alias Func,alias arg,args...)() {
return Func(arg,args);
}
where Func is called with 'arg' followed by the 'args'
On Sunday, 5 February 2017 at 20:36:57 UTC, Mark Fisher wrote:
I want to write a template:
static auto ref BindArg(alias Func,alias arg,args...)() {
return Func(arg,args);
}
where Func is called with 'arg' followed by the 'args'
parameters.
eg:
string f(string a,int b,int c);
On Sunday, 5 February 2017 at 20:36:57 UTC, Mark Fisher wrote:
static auto ref BindArg(alias Func,alias arg,args...)() {
return Func(arg,args);
}
[...]
BindArg(f,"1",2,3);
You forgot an exclamation mark there:
BindArg!(f,"1",2,3);
I want to write a template:
static auto ref BindArg(alias Func,alias arg,args...)() {
return Func(arg,args);
}
where Func is called with 'arg' followed by the 'args' parameters.
eg:
string f(string a,int b,int c);
BindArg(f,"1",2,3);
The compiler throws an error:
Error: function f
On Monday, 16 January 2017 at 16:08:07 UTC, Rene Zwanenburg wrote:
On Monday, 16 January 2017 at 15:56:16 UTC, Jack Stouffer wrote:
Same way you use any template parameters,
auto i = uniform!("(]")(0, 1000);
Also, if the template parameter consists of a single token you
On Monday, 16 January 2017 at 15:56:16 UTC, Jack Stouffer wrote:
Same way you use any template parameters,
auto i = uniform!("(]")(0, 1000);
Also, if the template parameter consists of a single token you
can omit the parens:
auto i = uniform!"(]"(0, 1000);
e template parameters?
Same way you use any template parameters,
auto i = uniform!("(]")(0, 1000);
Hey, quick question!
I'm messing around with std.random and noticed that you can
change the boundaries parameter to be either open or closed
intervals on either side. By default it is "[)". How do I
change these template parameters?
On Thursday, 11 August 2016 at 20:43:13 UTC, Meta wrote:
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine
wrote:
[...]
It can be done, but you have to be explicit and should think
very carefully if this is really a good design.
struct X(int defaultSize = 100)
{
int size;
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote:
I have the need, in some cases, to pass static information to a
template class but don't want it to affect its type.
import std.algorithm, core.stdc.stdlib;
struct X(int defaultSize = 100)
{
int Size;
int* p;
void
re, but the compiler considers them to be different types.
Each instantiation of a template defines a DIFFERENT namespace. The only
time the namespaces are identical are when the template parameters are
identical. The reason templates are so useful is because I don't HAVE to
write both S1 and S2.
On Thursday, 11 August 2016 at 18:42:51 UTC, Steven Schveighoffer
wrote:
On 8/11/16 2:11 PM, Engine Machine wrote:
I have the need, in some cases, to pass static information to
a template
class but don't want it to affect its type.
import std.algorithm, core.stdc.stdlib;
struct X(int
Also, what if we use a class instead of a struct?
in this case they are both references to the same thing.
I see a problem with reflection though, as one could get the
template parameter value and it would wrong on conversion. D
takes the easy way out of just preventing complex and
On Thursday, 11 August 2016 at 19:28:47 UTC, Lodovico Giaretta
wrote:
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine
wrote:
[...]
If, in your case, it is possible to use one type as the other,
then specify it.
I mean, implement a templated opAssign that allows you to
assign
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote:
[...]
If, in your case, it is possible to use one type as the other,
then specify it.
I mean, implement a templated opAssign that allows you to assign
values of one instantiation to values of another. While doing so,
On 8/11/16 2:42 PM, Steven Schveighoffer wrote:
On 8/11/16 2:11 PM, Engine Machine wrote:
I have the need, in some cases, to pass static information to a template
class but don't want it to affect its type.
import std.algorithm, core.stdc.stdlib;
struct X(int defaultSize = 100)
{
int Size;
On 08/11/2016 11:11 AM, Engine Machine wrote:
> I have the need, in some cases, to pass static information to a template
> class but don't want it to affect its type.
>
> import std.algorithm, core.stdc.stdlib;
> struct X(int defaultSize = 100)
> {
>int Size;
>int* p;
>void foo(int
On 8/11/16 2:11 PM, Engine Machine wrote:
I have the need, in some cases, to pass static information to a template
class but don't want it to affect its type.
import std.algorithm, core.stdc.stdlib;
struct X(int defaultSize = 100)
{
int Size;
int* p;
void foo(int size)
{
Size =
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote:
Is there any way to get D to understand I want do not want a
template parameter to be part of the type comparison?
No. Use a standard run-time parameter. Your problem can be solved
by defining a constructor.
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote:
I have the need, in some cases, to pass static information to a
template class but don't want it to affect its type.
import std.algorithm, core.stdc.stdlib;
struct X(int defaultSize = 100)
{
int Size;
int* p;
void
I have the need, in some cases, to pass static information to a
template class but don't want it to affect its type.
import std.algorithm, core.stdc.stdlib;
struct X(int defaultSize = 100)
{
int Size;
int* p;
void foo(int size)
{
Size = max(size, defaultSize);
p =
On Wednesday, 15 June 2016 at 23:52:56 UTC, Basile B. wrote:
On Wednesday, 15 June 2016 at 22:27:38 UTC, pineapple wrote:
Here's a simple code example to illustrate what I expected to
work and didn't - is this a mistake in my syntax or a
limitation of the language?
template
On 6/15/16 7:52 PM, Basile B. wrote:
On Wednesday, 15 June 2016 at 22:27:38 UTC, pineapple wrote:
Here's a simple code example to illustrate what I expected to work and
didn't - is this a mistake in my syntax or a limitation of the language?
template SomeTemplate(alias func){
auto
On Wednesday, 15 June 2016 at 22:27:38 UTC, pineapple wrote:
Here's a simple code example to illustrate what I expected to
work and didn't - is this a mistake in my syntax or a
limitation of the language?
template SomeTemplate(alias func){
auto templatefunc(T)(int x){
Here's a simple code example to illustrate what I expected to
work and didn't - is this a mistake in my syntax or a limitation
of the language?
template SomeTemplate(alias func){
auto templatefunc(T)(int x){
return func!T(x);
}
}
// Valid
auto
On Tuesday, 16 February 2016 at 19:00:19 UTC, Ali Çehreli wrote:
std.traits.TemplateArgsOf:
http://dlang.org/phobos/std_traits.html#TemplateArgsOf
import std.traits;
class Foo(type1,type2)
{}
class Bar(FooType)
{
// pragma(msg, TemplateArgsOf!FooType);
alias ReturnType =
On 02/16/2016 10:34 AM, Gavin Maye wrote:
Say you have
class Foo(type1,type2)
{
}
And a concrete Foo is passed as a parameter to another template, is
there a way to get type1 and type2 from Foo so you can use them in the
new template... For example..
class Bar(FooType)
{
Say you have
class Foo(type1,type2)
{
}
And a concrete Foo is passed as a parameter to another template,
is there a way to get type1 and type2 from Foo so you can use
them in the new template... For example..
class Bar(FooType)
{
FooType.type1 DoSomething() { ... }
}
or Even
On Tuesday, 2 February 2016 at 13:57:54 UTC, Marc Schütz wrote:
On Tuesday, 2 February 2016 at 13:52:55 UTC, Marc Schütz wrote:
The last call should work IMO, but it doesn't. I believe
that's a compiler bug.
Filed:
https://issues.dlang.org/show_bug.cgi?id=15640
I would say it is not a bug
On Tuesday, 2 February 2016 at 14:47:43 UTC, Marc Schütz wrote:
On Tuesday, 2 February 2016 at 14:12:54 UTC, Daniel Kozak wrote:
On Tuesday, 2 February 2016 at 13:57:54 UTC, Marc Schütz wrote:
On Tuesday, 2 February 2016 at 13:52:55 UTC, Marc Schütz
wrote:
The last call should work IMO, but it
On Tuesday, 2 February 2016 at 13:52:55 UTC, Marc Schütz wrote:
On Tuesday, 2 February 2016 at 13:20:33 UTC, Voitech wrote:
[...]
Two possible solutions... If you don't need to know the number
of arguments at compile time, you can use normal variadic
arguments:
[...]
Thank you I'll try
On Tuesday, 2 February 2016 at 14:55:42 UTC, Daniel Kozak wrote:
On Tuesday, 2 February 2016 at 14:47:43 UTC, Marc Schütz wrote:
if you mix ints and floats, the common type is deduced
correctly:
this is a bug for me :). I do not like this. I am ok with
(u)byte to int conversion and similar,
On Tuesday, 2 February 2016 at 14:12:54 UTC, Daniel Kozak wrote:
On Tuesday, 2 February 2016 at 13:57:54 UTC, Marc Schütz wrote:
On Tuesday, 2 February 2016 at 13:52:55 UTC, Marc Schütz wrote:
The last call should work IMO, but it doesn't. I believe
that's a compiler bug.
Filed:
Hi, Is it possible to bound T... in template with some type ? For
single Parameter declaration it can be done by T:SomeType but
variadics does not seems to have that possibility ?
Cheers
On Tuesday, 2 February 2016 at 13:20:33 UTC, Voitech wrote:
Hi, Is it possible to bound T... in template with some type ?
For single Parameter declaration it can be done by T:SomeType
but variadics does not seems to have that possibility ?
Cheers
import std.stdio;
import std.meta:
On Tuesday, 2 February 2016 at 13:52:55 UTC, Marc Schütz wrote:
The last call should work IMO, but it doesn't. I believe that's
a compiler bug.
Filed:
https://issues.dlang.org/show_bug.cgi?id=15640
On Monday, 11 January 2016 at 00:50:37 UTC, Ilya Yaroshenko wrote:
I will add such function. But it is not safe to do so (Slice
can have strides not equal to 1). So it is like a hack ([0,
0, 0])[0 .. ret.elementsCount]).
Have you made comparison between my and yours parallel versions?
On Sunday, 10 January 2016 at 22:23:18 UTC, Ilya Yaroshenko wrote:
Could you please provide full code and error (git gists)? --
Ilya
ok, thanks.
I'm building with DMD32 D Compiler v2.069.2 on Win32. The
dub.json is included.
https://gist.github.com/jnorwood/affd05b69795c20989a3
On Sunday, 10 January 2016 at 23:24:24 UTC, Jay Norwood wrote:
On Sunday, 10 January 2016 at 22:23:18 UTC, Ilya Yaroshenko
wrote:
Could you please provide full code and error (git gists)? --
Ilya
ok, thanks.
I'm building with DMD32 D Compiler v2.069.2 on Win32. The
dub.json is included.
On Sunday, 10 January 2016 at 23:31:47 UTC, Ilya Yaroshenko wrote:
Just use normal arrays for buffer (median accepts array on
second argument for optimisation reasons).
ok, I think I see. I created a slice(numTasks, bigd) over an
allocated double[] dbuf, but slb[task] will be returning some
On Monday, 11 January 2016 at 00:39:04 UTC, Jay Norwood wrote:
On Sunday, 10 January 2016 at 23:31:47 UTC, Ilya Yaroshenko
wrote:
Just use normal arrays for buffer (median accepts array on
second argument for optimisation reasons).
ok, I think I see. I created a slice(numTasks, bigd) over an
I cut this median template from Jack Stouffer's article and was
attempting to use it in a parallel function. As shown, it
builds and execute correctly, but it failed to compile if I
attempting to use
medians[i] = median(vec,slb[task]);
in place of the
medians[i] = median(vec,dbuf[j .. k]);
On Sunday, 10 January 2016 at 22:00:20 UTC, Jay Norwood wrote:
I cut this median template from Jack Stouffer's article and was
attempting to use it in a parallel function. As shown, it
builds and execute correctly, but it failed to compile if I
attempting to use
medians[i] =
On Sunday, 10 January 2016 at 23:24:24 UTC, Jay Norwood wrote:
On Sunday, 10 January 2016 at 22:23:18 UTC, Ilya Yaroshenko
wrote:
Could you please provide full code and error (git gists)? --
Ilya
ok, thanks.
I'm building with DMD32 D Compiler v2.069.2 on Win32. The
dub.json is included.
On Saturday, 22 August 2015 at 16:49:26 UTC, DarthCthulhu wrote:
I'm having difficulty understanding how templates operate as
function parameters.
Say I have this:
struct ArrayTest {
void arrayTest(T) (T arrayT) {
writeln(arrayT);
}
}
unittest {
ArrayTest
);
test.arrayTest!(float, 1)(farray);
Sorry, that should be:
test.arrayTest!(float[], 1)(farray);
In your template declaration, you have declared two template
parameters, T and passing, and one function parameter, arrayT. It
is equivalent to:
template arrayTest(T, int passing) {
void arrayTest(T
to match):
void arrayTest(T, int passing) (T arrayT) { ... }
I get 'cannot deduce function from argument types' errors.
Specifically stating the type of the function doesn't seem to
help:
test.arrayTest(float [])(farray, 1);
There must be a way to mix template and non-template parameters,
right
On Thursday, 4 June 2015 at 13:38:20 UTC, Atila Neves wrote:
For regular runtime parameters, there's ParameterTypeTuple. How
would I write an equivalent template for template parameters?
i.e.
void fun(Foo foo, Bar bar)() {}
alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo
On Thursday, 2 April 2015 at 23:12:25 UTC, biozic wrote:
The code below doesn't compile. Why this error message?
---
struct Item {
int i;
}
struct Params {
Item* item;
this(int i) {
item = new Item(i); // line 9
}
}
struct Foo(Params params) {}
enum foo =
The code below doesn't compile. Why this error message?
---
struct Item {
int i;
}
struct Params {
Item* item;
this(int i) {
item = new Item(i); // line 9
}
}
struct Foo(Params params) {}
enum foo = Foo!(Params(1));
---
test.d(9): Error: Item(1) is not an lvalue
Hi,
in this minified example I try to expand the variadic parmaters of
foo to bar:
import std.typecons;
void foo(T ...)(T args)
{
bar(args.expand);
}
void bar(int i, string s){}
void main()
{
foo(1, a);
}
I got the syntax error: no property 'expand' for type '(int,
string)'
I
On Tuesday, 10 March 2015 at 19:11:22 UTC, André wrote:
Is there a simple way to get it working?
The simplest: just write `bar(args);` - the variadic arguments
will automatically expand.
On Tue, 10 Mar 2015 19:11:21 +, André wrote:
Hi,
in this minified example I try to expand the variadic parmaters of foo
to bar:
import std.typecons;
void foo(T ...)(T args)
{
bar(args.expand);
}
void bar(int i, string s){}
void main()
{
foo(1, a);
}
I
1 - 100 of 158 matches
Mail list logo