bindbc.sfml , sfVideoMode , Error: undefined identifier

2021-05-08 Thread Alain De Vos via Digitalmars-d-learn

I try this,
```
import bindbc.sfml;
import bindbc.sfml.config;
import bindbc.sfml.system;
import bindbc.sfml.window;
void main(){
bool ret=loadSFML();
sfVideoMode m=sfVideoMode(800, 600,24);
}
```
But dub gives undefined identifier sdVideoMode.
Although,
https://bindbc-sfml.dpldocs.info/bindbc.sfml.window.sfVideoMode.html
I must doing something wrong ?


Re: bindbc.sfml , sfVideoMode , Error: undefined identifier

2021-05-08 Thread Dennis via Digitalmars-d-learn

On Saturday, 8 May 2021 at 09:05:18 UTC, Alain De Vos wrote:

I must doing something wrong ?


Did you define the `SFML_Graphics` version like in the README of 
bindbc-sfml?




Re: bindbc.sfml , sfVideoMode , Error: undefined identifier

2021-05-08 Thread Alain De Vos via Digitalmars-d-learn

After adding
```
"versions": [
"SFML_Audio",
"SFML_Graphics",
"SFML_250",
]
```
to dub.json it compiles.
The sfml library the freebsd os is version : "sfml-2.5.1_2" .


Re: What does @nogc do to a class?

2021-05-08 Thread Jack via Digitalmars-d-learn

On Thursday, 6 May 2021 at 22:16:04 UTC, Per Nordlöw wrote:

On Thursday, 6 May 2021 at 01:04:02 UTC, Jack wrote:
Does it allocate the object rather on stack, like auto scope a 
= new A or what?


Further note that

auto scope a = new A;

can be written shorter as

scope a = new A;


I'll be using that, thanks!


Without multiples inheritance, how is this done?

2021-05-08 Thread Jack via Digitalmars-d-learn

let's say I have:

```d
class Base
{
int f()
{
doSomething();
return n * 5;
}

void doSomething() { }
}

class Foo : Base
{
void myMethod() { /* ... */ }
}

class Baa : Base
{
void myMethod2() { /* ... */ }
}
```

then I'd like to make a extended version(making those DRY 
routines a class itself) of Foo and Baa, like this:


```d
abstract class DRY : Base
{
this(int n)
{
this.n = n;
}

override int f()
{
super.doSomething();
return n;
}

private int n;
}
```

but the class ExtendFoo and ExtendedBaa  must inherit from Foo 
and Baa, respectively. But how can I make it inherit the routines 
from DRY class too without multiples inheritance? in C++ I'd just 
do:


```d
class ExtendedFoo : DRY, Base { /* ... */ }
class ExtendBaa : DRY, Base { /* ... */ }
```


Re: Without multiples inheritance, how is this done?

2021-05-08 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 8 May 2021 at 18:33:35 UTC, Jack wrote:

```d
abstract class DRY : Base
{
this(int n)
{
this.n = n;
}

override int f()
{
super.doSomething();
return n;
}

private int n;
}
```


You can change that from abstract class to `mixin template`, make 
Foo and Baa be `interface`, then use `mixin DRY;` inside your 
child class.




Re: Without multiples inheritance, how is this done?

2021-05-08 Thread matheus via Digitalmars-d-learn

On Saturday, 8 May 2021 at 18:33:35 UTC, Jack wrote:

...
but the class ExtendFoo and ExtendedBaa  must inherit from Foo 
and Baa, respectively. But how can I make it inherit the 
routines from DRY class too without multiples inheritance? in 
C++ I'd just do:


class ExtendedFoo : DRY, Base { /* ... */ }
class ExtendBaa : DRY, Base { /* ... */ }


What about this model:

class baseFoo{
   // Implement foo stuff
}

class baseFooBar : baseFoo{
   // Implement bar stuff
}

class FooBar : baseFooBar{
   // Do your FooBar thing!
}

Matheus.


Is there any bettter solution to Windows wide string

2021-05-08 Thread Vinod K Chandran via Digitalmars-d-learn

Hi all,
I am planning some win32 hobby projects. Now I have this function 
to tackle the LPCWSTR data type in win32.

```d
private import std.utf;
auto toWString(S)(S s) { return toUTFz!(const(wchar)*)(s); }
```
Is there any better way to do this ?


Re: Is there any bettter solution to Windows wide string

2021-05-08 Thread Imperatorn via Digitalmars-d-learn

On Saturday, 8 May 2021 at 20:50:10 UTC, Vinod K Chandran wrote:

Hi all,
I am planning some win32 hobby projects. Now I have this 
function to tackle the LPCWSTR data type in win32.

```d
private import std.utf;
auto toWString(S)(S s) { return toUTFz!(const(wchar)*)(s); }
```
Is there any better way to do this ?


iirc that's toUTF16z


Re: Is there any bettter solution to Windows wide string

2021-05-08 Thread Vinod K Chandran via Digitalmars-d-learn

On Saturday, 8 May 2021 at 21:26:06 UTC, Imperatorn wrote:



iirc that's toUTF16z


Thanks. Let me check. :)