On Wednesday, 27 June 2018 at 17:07:52 UTC, Jonathan M Davis
wrote:
On Wednesday, June 27, 2018 16:19:56 Luka Aleksic via
Digitalmars-d-learn wrote:
[...]
[...]
Well, for one, what's on the left side of the = doesn't
normally affect the type of what's on the right. It does in
some cases w
On Wednesday, 27 June 2018 at 16:19:56 UTC, Luka Aleksic wrote:
[…]
I am getting the following error:
scratch.d(14): Error: struct scratch.pair cannot deduce
function from argument types !()(char, int), candidates are:
scratch.d(2):scratch.pair(T, U)
Failed: ["/usr/bin/dmd", "-v", "-o-
On Wed, Jun 27, 2018 at 04:19:56PM +, Luka Aleksic via Digitalmars-d-learn
wrote:
[...]
> struct pair(T, U) {
> T first;
> U second;
>
> this(T arg_first, U arg_second) {
> first = arg_first;
> second = arg_second;
> }
> };
>
> void main()
On Wednesday, June 27, 2018 16:19:56 Luka Aleksic via Digitalmars-d-learn
wrote:
> Hello,
>
> In the following code:
>
> T first;
> U second;
>
> this(T arg_first, U arg_second) {
> first = arg_first;
> second = arg_second;
> }
> };
>
> void main() {
>
> pair!(char, uint) p1
Hello,
In the following code:
struct pair(T, U) {
T first;
U second;
this(T arg_first, U arg_second) {
first = arg_first;
second = arg_second;
}
};
void main() {
pair!(char, uint) p1 = pair('a', 1);
}
I am getting the f
On Friday, 23 June 2017 at 00:54:36 UTC, Petar Kirov [ZombineDev]
wrote:
On Thursday, 22 June 2017 at 21:19:43 UTC, Boris-Barboris wrote:
On Thursday, 22 June 2017 at 21:16:40 UTC, Ali Çehreli wrote:
And yes, there should be one destructor, which may be a no-op
if you grab its resource and set
On Thursday, 22 June 2017 at 21:19:43 UTC, Boris-Barboris wrote:
On Thursday, 22 June 2017 at 21:16:40 UTC, Ali Çehreli wrote:
And yes, there should be one destructor, which may be a no-op
if you grab its resource and set it to null.
On all compilers...
That's a relief, thank you for your he
On Thursday, 22 June 2017 at 21:16:40 UTC, Ali Çehreli wrote:
And yes, there should be one destructor, which may be a no-op
if you grab its resource and set it to null.
On all compilers...
That's a relief, thank you for your help.
On 06/22/2017 02:08 PM, Boris-Barboris wrote:
On Thursday, 22 June 2017 at 20:05:46 UTC, Ali Çehreli wrote:
To be complete, 'auto ref' passes lvalues by reference and rvalues by
value, which you can detect with __traits(isRef):
struct S{
}
void foo()(auto ref S s) {
static if (__traits(isR
On Thursday, 22 June 2017 at 20:05:46 UTC, Ali Çehreli wrote:
To be complete, 'auto ref' passes lvalues by reference and
rvalues by value, which you can detect with __traits(isRef):
struct S{
}
void foo()(auto ref S s) {
static if (__traits(isRef, s)) {
pragma(msg, "lvalue");
}
On 06/22/2017 12:57 PM, Boris-Barboris wrote:
> On Thursday, 22 June 2017 at 19:17:13 UTC, Ali Çehreli wrote:
>> No time to think about the rest of the design but just to get the code
>> compiled, replace 'ref' with 'auto ref' like so:
>
> Ok, looks like this indeed passes rhs by reference, thank
On Thursday, 22 June 2017 at 19:17:13 UTC, Ali Çehreli wrote:
No time to think about the rest of the design but just to get
the code compiled, replace 'ref' with 'auto ref' like so:
Ok, looks like this indeed passes rhs by reference, thank you.
destcalls - number of times UniquePtr destructor
On Thursday, 22 June 2017 at 19:17:13 UTC, Ali Çehreli wrote:
No time to think about the rest of the design but just to get
the code compiled, replace 'ref' with 'auto ref' like so:
this(DT)(scope auto ref UniquePtr!DT rhs)
{
// ...
}
Ali
i added this static variable:
st
On 06/22/2017 12:06 PM, Boris-Barboris wrote:
> Hi
>
> https://dpaste.dzfl.pl/0def4e286564
>
> Is there a cleaner way to go than the one on the line 26? And why is the
> constructor
>
> /d475/f781.d(37): f781.UniquePtr!(A).UniquePtr.__ctor(DT)(ref scope
> UniquePtr!DT rhs)
>
> unfit for line 51?
>
Hi
https://dpaste.dzfl.pl/0def4e286564
Is there a cleaner way to go than the one on the line 26? And why
is the constructor
/d475/f781.d(37): f781.UniquePtr!(A).UniquePtr.__ctor(DT)(ref
scope UniquePtr!DT rhs)
unfit for line 51?
Is it because the expression " = UniquePtr!B.make()" cannot b
On Monday, 3 November 2014 at 17:05:21 UTC, John Colvin wrote:
static if (is(typeof(T) == int))
should be
static if (is(T == int))
T is already a type.
I thought this was supposed to produce an error message rather
than fail silently... I'm positive this used to be an error. Did
it change
On Monday, 3 November 2014 at 17:03:33 UTC, deed wrote:
struct Internal { int i; double d; string s; }
struct External_int {
Internal internal;
@property Internal* ptr () { return &internal; }
this (int a)
{
internal.s = "int";
internal.i = a;
}
}
struct External (T)
static if (is(typeof(T) == int))
should be
static if (is(T == int))
T is already a type.
Ahh. Thanks!
struct Internal { int i; double d; string s; }
struct External_int {
Internal internal;
@property Internal* ptr () { return &internal; }
this (int a)
{
internal.s = "int";
internal.i = a;
}
}
struct External (T) {
Internal internal;
@property Internal* ptr () { ret
On Saturday, 12 July 2014 at 19:42:13 UTC, Ali Çehreli wrote:
Actually, that works too but members must be initialized from
the beginning. The trailing ones are left with .init values:
struct S
{
int i;
string s;
}
void main()
{
auto s = new S(42);
static assert(is (typeof(s) =
On 07/12/2014 12:38 PM, Danyal Zia wrote:
> You can initialize in constructor this(), but you can't initialize
> partial fields of struct when using pointer to struct.
Actually, that works too but members must be initialized from the
beginning. The trailing ones are left with .init values:
st
On Saturday, 12 July 2014 at 19:32:48 UTC, seany wrote:
do I have to initialize all variables of the struct? or may I
also use a this(){} in the struct and initialize only those
which are known at a given moment?
You can initialize in constructor this(), but you can't
initialize partial field
On 07/12/2014 12:32 PM, seany wrote:
> do I have to initialize all variables of the struct?
No. The uninitialized ones get their .init values.
> or may I also use a
> this(){} in the struct and initialize only those which are known at a
> given moment?
That already works with structs. You don'
On 07/12/2014 12:19 PM, seany wrote:
> On Saturday, 12 July 2014 at 19:16:52 UTC, Danyal Zia wrote:
>> On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
>>>arc!(string, string[]) * a;
>>>a.some_var = "hello";
>> "a" has not been instantiated. You are declaring it as a pointer to
>
do I have to initialize all variables of the struct? or may I
also use a this(){} in the struct and initialize only those which
are known at a given moment?
On Saturday, 12 July 2014 at 19:19:28 UTC, seany wrote:
For reasons further down in the software, I need to do this
with a pointer. How do I do it with a pointer, please?
I don't know what are you trying to achieve, but if that's what
you want, you can do:
void MYfunction()
{
auto strArr
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string, string[]) * a;
a.some_var = "hello";
}
}
void main()
{
On Saturday, 12 July 2014 at 19:16:52 UTC, Danyal Zia wrote:
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string, string[
Also, (*c).MYfunction() is leading to segmentation fault
sorry, I meant (*a).some_var
not (*c).MYfunction()
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string, string[]) * a;
a.some_var = "hello";
}
}
void main()
{
c = new myclass();
c.MYfunction();
}
This leads to a
On Tuesday, 4 February 2014 at 11:01:01 UTC, Jakob Ovrum wrote:
On Tuesday, 4 February 2014 at 09:30:22 UTC, ed wrote:
Hi,
given a struct like so:
struct S(alias N, T) {...}
is there a way to get the template parameters of S? Something
like:
S.typetuple[0] == N,
S.typetuple[1] == T
I've h
On Tuesday, 4 February 2014 at 09:30:22 UTC, ed wrote:
Hi,
given a struct like so:
struct S(alias N, T) {...}
is there a way to get the template parameters of S? Something
like:
S.typetuple[0] == N,
S.typetuple[1] == T
I've had a look at std.typecons and std.typetuple but I don't
see what
On Tuesday, 4 February 2014 at 09:58:53 UTC, ed wrote:
On Tuesday, 4 February 2014 at 09:46:01 UTC, evilrat wrote:
On Tuesday, 4 February 2014 at 09:39:48 UTC, evilrat wrote:
On Tuesday, 4 February 2014 at 09:30:22 UTC, ed wrote:
Hi,
given a struct like so:
struct S(alias N, T) {...}
is the
On Tuesday, 4 February 2014 at 09:46:01 UTC, evilrat wrote:
On Tuesday, 4 February 2014 at 09:39:48 UTC, evilrat wrote:
On Tuesday, 4 February 2014 at 09:30:22 UTC, ed wrote:
Hi,
given a struct like so:
struct S(alias N, T) {...}
is there a way to get the template parameters of S? Something
On Tuesday, 4 February 2014 at 09:39:48 UTC, evilrat wrote:
On Tuesday, 4 February 2014 at 09:30:22 UTC, ed wrote:
Hi,
given a struct like so:
struct S(alias N, T) {...}
is there a way to get the template parameters of S? Something
like:
S.typetuple[0] == N,
S.typetuple[1] == T
I've had a
On Tuesday, 4 February 2014 at 09:30:22 UTC, ed wrote:
Hi,
given a struct like so:
struct S(alias N, T) {...}
is there a way to get the template parameters of S? Something
like:
S.typetuple[0] == N,
S.typetuple[1] == T
I've had a look at std.typecons and std.typetuple but I don't
see what
Hi,
given a struct like so:
struct S(alias N, T) {...}
is there a way to get the template parameters of S? Something
like:
S.typetuple[0] == N,
S.typetuple[1] == T
I've had a look at std.typecons and std.typetuple but I don't see
what I'm missing something and cannot see a way to do the ab
38 matches
Mail list logo