Re: Implicit conversion with ctor like C++

2015-09-08 Thread Pierre via Digitalmars-d-learn
I made a mistake it's more like: //Sample class class CClass { this(string MyValue){...} } //Called function void MyFunction(CClass MyClass){} void main() { MyFunction("Hello World!"); //Failed : MyFunction not callable... }

Re: Implicit conversion with ctor like C++

2015-09-08 Thread Pierre via Digitalmars-d-learn
OK that's very clear thank you for the answer.

Implicit conversion with ctor like C++

2015-09-08 Thread Pierre via Digitalmars-d-learn
Hi everybody, I would like to use implicit conversion like this: //Sample class class MyClass { this(string MyValue){...} } //Called function void MyFunction(Foo MyFoo){} void main() { MyFunction("Hello World!"); //Failed : MyFunction not callable... } I saw in forum this is OK

Re: Get AA key and value type

2015-09-20 Thread Pierre via Digitalmars-d-learn
On Saturday, 19 September 2015 at 18:13:09 UTC, Marc Schütz wrote: On Saturday, 19 September 2015 at 12:50:51 UTC, Pierre wrote: Hi everybody, I would like to extract key and value type from AA. You can also do it with built-in syntax: template AATypes(AA : K[V], K, V) { alias Key = K;

Re: Get AA key and value type

2015-09-20 Thread Pierre via Digitalmars-d-learn
On Sunday, 20 September 2015 at 09:34:15 UTC, Ali Çehreli wrote: On 09/20/2015 12:47 AM, Pierre wrote: I see, maybe .KeyType and .ValueType should be integrated in AA. Or like C++ with map, make a ValueType(::value_type) field wich contain a pair of type. Currently, they are templates in

Get AA key and value type

2015-09-19 Thread Pierre via Digitalmars-d-learn
Hi everybody, I would like to extract key and value type from AA. I found this answer on forum : template AATypes(T) { // todo: static assert if T is no AA type here alias ArrayElementType!(typeof(T.keys)) key; alias ArrayElementType!(typeof(T.values)) value; } But compiler failed,I

Re: Get AA key and value type

2015-09-19 Thread Pierre via Digitalmars-d-learn
On Saturday, 19 September 2015 at 12:52:19 UTC, ponce wrote: On Saturday, 19 September 2015 at 12:50:51 UTC, Pierre wrote: So how can I get types without instance ? Thanks for help. -->8- template AATypes(T) { // todo: static assert if T is no AA type here alias

Build utf.d with MS-COFF failed

2015-11-20 Thread Pierre via Digitalmars-d-learn
Hello, I can't build my project with MS-COFF option. I'm using DMD 2.069. I got this error : utf.d(1109) : invalid UTF-8 sequence (at index 1) I used these options with visual D: Compiler : DMD D-Version : D2 Output Type: DLL Subsystem : Not set Compilation: Combined

Re: Build utf.d with MS-COFF failed

2015-11-21 Thread Pierre via Digitalmars-d-learn
On Saturday, 21 November 2015 at 01:18:38 UTC, Charles wrote: What string is throwing the error? I've had that error when I was trying to decode windows1252 strings. Thank you for your answer, but it's not a compilation error, it's a message box displayed when i lauch compilation. I asked

Access private member

2016-06-13 Thread Pierre via Digitalmars-d-learn
Hi, I would like to know how can i access private member of class from outside ? I think about serialization for instance, serializer must have access to protected attributes. How this is done ? Thank you.

Re: Access private member

2016-06-13 Thread Pierre via Digitalmars-d-learn
Thank you i will try it.

Re: Generic test bit function (core.bitop)

2018-03-08 Thread Pierre via Digitalmars-d-learn
On Wednesday, 7 March 2018 at 13:26:06 UTC, Alex wrote: From this point of view, size_t is not fixed, but capable to point to any place in memory. Therefore, pointer of any type have by definition exactly the defined size of size_t. Thank you,I thougth that pointer aliasing wasn't allowed.

Generic test bit function (core.bitop)

2018-03-06 Thread Pierre via Digitalmars-d-learn
Hi all, I would like to use bt function (core.bitop) on generic array but it seems that's not possible. I would like to know if there is some reasons to have a fixed type (size_t) instead of something like : pure @system int bt(T)(in T* p,size_t bitnum) if(__traits(isIntegral,T)) {

Re: "this" as default parameter for a constructor.

2021-04-13 Thread Pierre via Digitalmars-d-learn
On Monday, 12 April 2021 at 13:14:27 UTC, Kagamin wrote: class foo { this ( foo p /* , other params */ ) { parent = p; } foo create() { return new foo(this); } void use() { foo f = create(); }

"this" as default parameter for a constructor.

2021-04-11 Thread Pierre via Digitalmars-d-learn
Hi, I have a class with a reference to the parent object and a constructor that has the parent as parameter class foo { this ( foo p /* , other params */ ) { parent = p; } foo parent; } Of cause, the parent is almost always the object that creates the

Re: Looking for a little help with the win32 headers

2015-03-25 Thread Jean pierre via Digitalmars-d-learn
On Thursday, 26 March 2015 at 04:52:23 UTC, Belly wrote: Hello, just installed D today. I have this code: import std.stdio; import win32.windef; import win32.winbase; void main() { LPSTR lpBuffer; PDWORD lpnSize; int result = GetComputerNameA(lpBuffer, lpnSize);

Re: Problem overloading operator for a struct with an immutable member

2015-03-25 Thread Jean pierre via Digitalmars-d-learn
On Thursday, 26 March 2015 at 04:57:55 UTC, ketmar wrote: On Tue, 24 Mar 2015 16:49:01 +, Nicolas Sicard wrote: I don't know if this is a bug or expected behaviour. The struct is mutable, assignable and pre-increment operator works. But post-increment doesn't compile because of the

Getting usages of template

2016-11-17 Thread Carlin St Pierre via Digitalmars-d-learn
Is it possible to get the list of usages of a template during compile time? For example: class Foo { void bar(T)(T t) { } } void main() { Foo foo = new Foo; foo.bar(1); // int foo.bar(2f); // float foo.bar("3"); // string } //