I'm trying to learn C++ after being spoiled with high-level languages for all of my life.
I would like to use the fluent design pattern with a class, but I'm worried that I'm making a mistake somewhere and sacrificing performance.
Say that I have a class Builder
, and it has some member properties and methods. All of it's methods look something like so:
Builder &doSomething(SomeTypeThatCouldBeAClassOrAPrimitive &thing)
{
// do stuff, such as
// modify a class member
memberThing = "something";
return *thing;
}
And say that I'm using it like so:
unique_ptr<Builder> builder(new Builder());
builder->doSomething(someVal)
.doAnotherThing(someOtherVal)
.doAFinalThing(someOtherOtherVal);
Just from the code provided, am I doing something wrong, or could something be done more efficiently?
Please let me know if I need to provide more information.
Aucun commentaire:
Enregistrer un commentaire