On Monday, 7 March 2016 at 18:44:01 UTC, Namespace wrote:
Honestly speaking, I think this case is impossible to solve in
C++. I'll show my fellow students the advantages of D over C++
in next couple of weeks, and this example is pretty good. :)
:-) Good luck!
On Monday, 7 March 2016 at 18:17:18 UTC, Ola Fosheim Grøstad
wrote:
On Monday, 7 March 2016 at 16:30:48 UTC, Namespace wrote:
Thanks to the wildcard modifier inout. Is there any possible
way to do the same in C++?
In this specific case you could do it with a macro if you don't
mind dirty
On Monday, 7 March 2016 at 16:30:48 UTC, Namespace wrote:
Thanks to the wildcard modifier inout. Is there any possible
way to do the same in C++?
In this specific case you could do it with a macro if you don't
mind dirty macros, but you really should implement the const
version explicitly or
Let's use an example:
import std.stdio;
class Visitor {
public:
void visit(inout A) {
writeln("visit A");
}
void visit(inout B) {
writeln("visit B");
}
}
class A {
public:
void accept(Visitor v) inout {
v.visit(this);
}
}
class B : A {
On Monday, 7 March 2016 at 10:52:53 UTC, Ola Fosheim Grøstad
wrote:
On Sunday, 6 March 2016 at 17:53:47 UTC, Namespace wrote:
What would be the C++ way? Is there any comfortable way to
solve this problem in a nice way like D?
C++ has a non-idiomatic language culture. There are many ways
to
On Sunday, 6 March 2016 at 17:53:47 UTC, Namespace wrote:
What would be the C++ way? Is there any comfortable way to
solve this problem in a nice way like D?
C++ has a non-idiomatic language culture. There are many ways to
do it. One clean way could be to use a templated method, another
way
On Thursday, 25 February 2016 at 10:59:43 UTC, Rene Zwanenburg
wrote:
On Thursday, 25 February 2016 at 10:44:49 UTC, Andrea Fontana
wrote:
Check this simple code:
http://dpaste.dzfl.pl/2772c9144f1c
I can't understand how to minimize code duplication for
function like get().
Of course on real
On Thursday, 25 February 2016 at 10:44:49 UTC, Andrea Fontana
wrote:
Check this simple code:
http://dpaste.dzfl.pl/2772c9144f1c
I can't understand how to minimize code duplication for
function like get().
Of course on real case body is much bigger and complex than
that.
The only way I found
On Thursday, 25 February 2016 at 10:48:34 UTC, Namespace wrote:
Try inout:
import std.stdio;
struct Inner
{
int field = 3;
}
struct Test
{
auto get() inout { return inner; }
private Inner inner;
}
void main()
{
{
Try inout:
import std.stdio;
struct Inner
{
int field = 3;
}
struct Test
{
auto get() inout { return inner; }
private Inner inner;
}
void main()
{
{
Test test;
test.get.field = 4;
}
Check this simple code:
http://dpaste.dzfl.pl/2772c9144f1c
I can't understand how to minimize code duplication for function
like get().
Of course on real case body is much bigger and complex than that.
The only way I found is to move the body of function inside a
mixin template:
mixin
11 matches
Mail list logo