- 1.1k
- 3
- 14
- 27
There are several small things that you can easily improve:
Tell me if I am mistaken, but it seems that the macro
PNEU_EXCEPT_TO_METHODRES
needs some trailingwhile (0)
if you don't want to add it manually everytimeevery time you invoke it.In
MethodResult
, you explicitlydefault
ed the copy constructor and the destructor. You could actually totally get rid of these lines by using the rule of zero rule of zero: don't write any copy/move constructors/operators, and the compiler will generate them for. Unless you intend to make a non-copyable class or a RAII one, you generally want to use the rule of zero.If you want to copy a
string
, don't pass it byconst&
, but use the copy-then-move idiom instead:MethodResult(bool ok, std::string desc) : fOk(ok), fDescription(std::move(desc)) { }
The function trailing
return
type is fine, but if you want to get the readbilityreadability benefits, you can put the type name on the following line. That really helps to visually separate thereturn
type and avoids having overly long function declarations. That said, it is most useful when you have long template types.static auto ok() -> MethodResult { return MethodResult(true, ""); }
Note that I did not chose the best function to prove my point. However, this allows to split long declarations in two lines and still have both the function names and the return types aligned. Example with
Window
class declaration:auto update() -> void; auto pollEvents() -> void; auto renderFrame() -> void;
The obvious drawback is of course the fact that the declaration now takes two lines. There is a choice to make, and it is yours.
You can use list initialization in a
return
statement when you create and return an object and the same line. That will help avoiding to repeat the type:static auto ok() -> MethodResult { return { true, "" }; }
Two small things concerning your
main
: don't bother to addargc
andargv
if you are not going to use them. You don't have to writereturn 0;
at the end ofmain
; if the compiler reaches the end ofmain
without having encountered areturn
statement, it will automatically add areturn 0;
.
There are several small things that you can easily improve:
Tell me if I am mistaken, but it seems that the macro
PNEU_EXCEPT_TO_METHODRES
needs some trailingwhile (0)
if you don't want to add it manually everytime you invoke it.In
MethodResult
, you explicitlydefault
ed the copy constructor and the destructor. You could actually totally get rid of these lines by using the rule of zero: don't write any copy/move constructors/operators, and the compiler will generate them for. Unless you intend to make a non-copyable class or a RAII one, you generally want to use the rule of zero.If you want to copy a
string
, don't pass it byconst&
, but use the copy-then-move idiom instead:MethodResult(bool ok, std::string desc) : fOk(ok), fDescription(std::move(desc)) { }
The function trailing
return
type is fine, but if you want to get the readbility benefits, you can put the type name on the following line. That really helps to visually separate thereturn
type and avoids having overly long function declarations. That said, it is most useful when you have long template types.static auto ok() -> MethodResult { return MethodResult(true, ""); }
Note that I did not chose the best function to prove my point. However, this allows to split long declarations in two lines and still have both the function names and the return types aligned. Example with
Window
class declaration:auto update() -> void; auto pollEvents() -> void; auto renderFrame() -> void;
The obvious drawback is of course the fact that the declaration now takes two lines. There is a choice to make, and it is yours.
You can use list initialization in a
return
statement when you create and return an object and the same line. That will help avoiding to repeat the type:static auto ok() -> MethodResult { return { true, "" }; }
Two small things concerning your
main
: don't bother to addargc
andargv
if you are not going to use them. You don't have to writereturn 0;
at the end ofmain
; if the compiler reaches the end ofmain
without having encountered areturn
statement, it will automatically add areturn 0;
.
There are several small things that you can easily improve:
Tell me if I am mistaken, but it seems that the macro
PNEU_EXCEPT_TO_METHODRES
needs some trailingwhile (0)
if you don't want to add it manually every time you invoke it.In
MethodResult
, you explicitlydefault
ed the copy constructor and the destructor. You could actually totally get rid of these lines by using the rule of zero: don't write any copy/move constructors/operators, and the compiler will generate them for. Unless you intend to make a non-copyable class or a RAII one, you generally want to use the rule of zero.If you want to copy a
string
, don't pass it byconst&
, but use the copy-then-move idiom instead:MethodResult(bool ok, std::string desc) : fOk(ok), fDescription(std::move(desc)) { }
The function trailing
return
type is fine, but if you want to get the readability benefits, you can put the type name on the following line. That really helps to visually separate thereturn
type and avoids having overly long function declarations. That said, it is most useful when you have long template types.static auto ok() -> MethodResult { return MethodResult(true, ""); }
Note that I did not chose the best function to prove my point. However, this allows to split long declarations in two lines and still have both the function names and the return types aligned. Example with
Window
class declaration:auto update() -> void; auto pollEvents() -> void; auto renderFrame() -> void;
The obvious drawback is of course the fact that the declaration now takes two lines. There is a choice to make, and it is yours.
You can use list initialization in a
return
statement when you create and return an object and the same line. That will help avoiding to repeat the type:static auto ok() -> MethodResult { return { true, "" }; }
Two small things concerning your
main
: don't bother to addargc
andargv
if you are not going to use them. You don't have to writereturn 0;
at the end ofmain
; if the compiler reaches the end ofmain
without having encountered areturn
statement, it will automatically add areturn 0;
.
There are several small things that you can easily improve:
Tell me if I am mistaken, but it seems that the macro
PNEU_EXCEPT_TO_METHODRES
needs some trailingwhile (0)
if you don't want to add it manually everytime you invoke it.In
MethodResult
, you explicitlydefault
ed the copy constructor and the destructor. You could actually totally get rid of these lines by using the rule of zero: don't write any copy/move constructors/operators, and the compiler will generate them for. Unless you intend to make a non-copyable class or a RAII one, you generally want to use the rule of zero.If you want to copy a
string
, don't pass it byconst&
, but use the copy-then-move copy-then-move idiom instead:MethodResult(bool ok, std::string desc) : fOk(ok), fDescription(std::move(desc)) { }
The function trailing
return
type is fine, but if you want to get the readbility benefits, you can put the type name on the following line. That really helps to visually separate thereturn
type and avoids having overly long function declarations. That said, it is most useful when you have long template types.static auto ok() -> MethodResult { return MethodResult(true, ""); }
Note that I did not chose the best function to prove my point. However, this allows to split long declarations in two lines and still have both the function names and the return types aligned. Example with
Window
class declaration:auto update() -> void; auto pollEvents() -> void; auto renderFrame() -> void;
The obvious drawback is of course the fact that the declaration now takes two lines. There is a choice to make, and it is yours.
You can use list initialization in a
return
statement when you create and return an object and the same line. That will help avoiding to repeat the type:static auto ok() -> MethodResult { return { true, "" }; }
Two small things concerning your
main
: don't bother to addargc
andargv
if you are not going to use them. You don't have to writereturn 0;
at the end ofmain
; if the compiler reaches the end ofmain
without having encountered areturn
statement, it will automatically add areturn 0;
.
There are several small things that you can easily improve:
Tell me if I am mistaken, but it seems that the macro
PNEU_EXCEPT_TO_METHODRES
needs some trailingwhile (0)
if you don't want to add it manually everytime you invoke it.In
MethodResult
, you explicitlydefault
ed the copy constructor and the destructor. You could actually totally get rid of these lines by using the rule of zero: don't write any copy/move constructors/operators, and the compiler will generate them for. Unless you intend to make a non-copyable class or a RAII one, you generally want to use the rule of zero.If you want to copy a
string
, don't pass it byconst&
, but use the copy-then-move idiom instead:MethodResult(bool ok, std::string desc) : fOk(ok), fDescription(std::move(desc)) { }
The function trailing
return
type is fine, but if you want to get the readbility benefits, you can put the type name on the following line. That really helps to visually separate thereturn
type and avoids having overly long function declarations. That said, it is most useful when you have long template types.static auto ok() -> MethodResult { return MethodResult(true, ""); }
Note that I did not chose the best function to prove my point. However, this allows to split long declarations in two lines and still have both the function names and the return types aligned. Example with
Window
class declaration:auto update() -> void; auto pollEvents() -> void; auto renderFrame() -> void;
The obvious drawback is of course the fact that the declaration now takes two lines. There is a choice to make, and it is yours.
You can use list initialization in a
return
statement when you create and return an object and the same line. That will help avoiding to repeat the type:static auto ok() -> MethodResult { return { true, "" }; }
Two small things concerning your
main
: don't bother to addargc
andargv
if you are not going to use them. You don't have to writereturn 0;
at the end ofmain
; if the compiler reaches the end ofmain
without having encountered areturn
statement, it will automatically add areturn 0;
.
There are several small things that you can easily improve:
Tell me if I am mistaken, but it seems that the macro
PNEU_EXCEPT_TO_METHODRES
needs some trailingwhile (0)
if you don't want to add it manually everytime you invoke it.In
MethodResult
, you explicitlydefault
ed the copy constructor and the destructor. You could actually totally get rid of these lines by using the rule of zero: don't write any copy/move constructors/operators, and the compiler will generate them for. Unless you intend to make a non-copyable class or a RAII one, you generally want to use the rule of zero.If you want to copy a
string
, don't pass it byconst&
, but use the copy-then-move idiom instead:MethodResult(bool ok, std::string desc) : fOk(ok), fDescription(std::move(desc)) { }
The function trailing
return
type is fine, but if you want to get the readbility benefits, you can put the type name on the following line. That really helps to visually separate thereturn
type and avoids having overly long function declarations. That said, it is most useful when you have long template types.static auto ok() -> MethodResult { return MethodResult(true, ""); }
Note that I did not chose the best function to prove my point. However, this allows to split long declarations in two lines and still have both the function names and the return types aligned. Example with
Window
class declaration:auto update() -> void; auto pollEvents() -> void; auto renderFrame() -> void;
The obvious drawback is of course the fact that the declaration now takes two lines. There is a choice to make, and it is yours.
You can use list initialization in a
return
statement when you create and return an object and the same line. That will help avoiding to repeat the type:static auto ok() -> MethodResult { return { true, "" }; }
Two small things concerning your
main
: don't bother to addargc
andargv
if you are not going to use them. You don't have to writereturn 0;
at the end ofmain
; if the compiler reaches the end ofmain
without having encountered areturn
statement, it will automatically add areturn 0;
.
There are several small things that you can easily improve:
Tell me if I am mistaken, but it seems that the macro
PNEU_EXCEPT_TO_METHODRES
needs some trailingwhile (0)
if you don't want to add it manually everytime you invoke it.In
MethodResult
, you explicitlydefault
ed the copy constructor and the destructor. You could actually totally get rid of these lines by using the rule of zero: don't write any copy/move constructors/operators, and the compiler will generate them for. Unless you intend to make a non-copyable class or a RAII one, you generally want to use the rule of zero.If you want to copy a
string
, don't pass it byconst&
, but use the copy-then-move idiom instead:MethodResult(bool ok, std::string desc) : fOk(ok), fDescription(std::move(desc)) { }
The function trailing
return
type is fine, but if you want to get the readbility benefits, you can put the type name on the following line. That really helps to visually separate thereturn
type and avoids having overly long function declarations. That said, it is most useful when you have long template types.static auto ok() -> MethodResult { return MethodResult(true, ""); }
Note that I did not chose the best function to prove my point. However, this allows to split long declarations in two lines and still have both the function names and the return types aligned. Example with
Window
class declaration:auto update() -> void; auto pollEvents() -> void; auto renderFrame() -> void;
The obvious drawback is of course the fact that the declaration now takes two lines. There is a choice to make, and it is yours.
You can use list initialization in a
return
statement when you create and return an object and the same line. That will help avoiding to repeat the type:static auto ok() -> MethodResult { return { true, "" }; }
Two small things concerning your
main
: don't bother to addargc
andargv
if you are not going to use them. You don't have to writereturn 0;
at the end ofmain
; if the compiler reaches the end ofmain
without having encountered areturn
statement, it will automatically add areturn 0;
.
There are several small things that you can easily improve:
Tell me if I am mistaken, but it seems that the macro
PNEU_EXCEPT_TO_METHODRES
needs some trailingwhile (0)
if you don't want to add it manually everytime you invoke it.In
MethodResult
, you explicitlydefault
ed the copy constructor and the destructor. You could actually totally get rid of these lines by using the rule of zero: don't write any copy/move constructors/operators, and the compiler will generate them for. Unless you intend to make a non-copyable class or a RAII one, you generally want to use the rule of zero.The function trailing
return
type is fine, but if you want to get the readbility benefits, you can put the type name on the following line. That really helps to visually separate thereturn
type and avoids having overly long function declarations. That said, it is most useful when you have long template types.static auto ok() -> MethodResult { return MethodResult(true, ""); }
Note that I did not chose the best function to prove my point. However, this allows to split long declarations in two lines and still have both the function names and the return types aligned. Example with
Window
class declaration:auto update() -> void; auto pollEvents() -> void; auto renderFrame() -> void;
The obvious drawback is of course the fact that the declaration now takes two lines. There is a choice to make, and it is yours.
You can use list initialization in a
return
statement when you create and return an object and the same line. That will help avoiding to repeat the type:static auto ok() -> MethodResult { return { true, "" }; }
Two small things concerning your
main
: don't bother to addargc
andargv
if you are not going to use them. You don't have to writereturn 0;
at the end ofmain
; if the compiler reaches the end ofmain
without having encountered areturn
statement, it will automatically add areturn 0;
.
There are several small things that you can easily improve:
Tell me if I am mistaken, but it seems that the macro
PNEU_EXCEPT_TO_METHODRES
needs some trailingwhile (0)
if you don't want to add it manually everytime you invoke it.In
MethodResult
, you explicitlydefault
ed the copy constructor and the destructor. You could actually totally get rid of these lines by using the rule of zero: don't write any copy/move constructors/operators, and the compiler will generate them for. Unless you intend to make a non-copyable class or a RAII one, you generally want to use the rule of zero.If you want to copy a
string
, don't pass it byconst&
, but use the copy-then-move idiom instead:MethodResult(bool ok, std::string desc) : fOk(ok), fDescription(std::move(desc)) { }
The function trailing
return
type is fine, but if you want to get the readbility benefits, you can put the type name on the following line. That really helps to visually separate thereturn
type and avoids having overly long function declarations. That said, it is most useful when you have long template types.static auto ok() -> MethodResult { return MethodResult(true, ""); }
Note that I did not chose the best function to prove my point. However, this allows to split long declarations in two lines and still have both the function names and the return types aligned. Example with
Window
class declaration:auto update() -> void; auto pollEvents() -> void; auto renderFrame() -> void;
The obvious drawback is of course the fact that the declaration now takes two lines. There is a choice to make, and it is yours.
You can use list initialization in a
return
statement when you create and return an object and the same line. That will help avoiding to repeat the type:static auto ok() -> MethodResult { return { true, "" }; }
Two small things concerning your
main
: don't bother to addargc
andargv
if you are not going to use them. You don't have to writereturn 0;
at the end ofmain
; if the compiler reaches the end ofmain
without having encountered areturn
statement, it will automatically add areturn 0;
.