I just saw this post, which is essentially the same question as
Basile Burg's. I hope that a college (in France?) is teaching D
and that this is a homework assignment. Cool stuff! :)
Maybe using templates to create properties is a bit overkill in
this example. But I could not solve what I thou
On 12/30/2014 05:17 AM, Claude wrote:
> use templates to define several methods (property
> setters) within a class to avoid some code duplication.
I just saw this post, which is essentially the same question as Basile
Burg's. I hope that a college (in France?) is teaching D and that this
is a
Thanks Steven and Daniel for your explanations.
mixin template opAssign(alias Field) {
void opAssign(Tin)(auto ref Tin param) @property pure
@safe
{
Field = param;
m_matrixCalculated = false;
}
}
mixin opAssign!(m_pos) pos;
I tes
V Tue, 30 Dec 2014 13:17:08 +
Claude via Digitalmars-d-learn
napsáno:
> Hello, I'm trying to use templates to define several methods
> (property setters) within a class to avoid some code duplication.
> Here is an attempt:
>
> class Camera
> {
> private:
> Vector4 m_pos;
> float m
On 12/30/14 8:48 AM, Steven Schveighoffer wrote:
I think it has to do with the fact that when you are defining the
aliases, m_pos for example, is an *instance* member so requires an
instance to get an alias.
What you are probably better off doing is:
void SetProperty(Tin, string Field)(ref Tin
On 12/30/14 8:17 AM, Claude wrote:
Hello, I'm trying to use templates to define several methods (property
setters) within a class to avoid some code duplication.
Here is an attempt:
class Camera
{
private:
Vector4 m_pos;
float m_fov, m_ratio, m_near, m_far;
bool m_matrixCalculated
Hello, I'm trying to use templates to define several methods
(property setters) within a class to avoid some code duplication.
Here is an attempt:
class Camera
{
private:
Vector4 m_pos;
float m_fov, m_ratio, m_near, m_far;
bool m_matrixCalculated;
public:
void SetProperty(Tin, a