kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #24799
Re: [PATCH 04/12] Avoid C99 style compound statement
On Fri, May 27, 2016 at 04:32:51PM +0200, Simon Richter wrote:
>
> Support for C99 in C++ programs is a gcc extension.
> ---
> eeschema/autoplace_fields.cpp | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp
> index 9af6247..96ee6c0 100644
> --- a/eeschema/autoplace_fields.cpp
> +++ b/eeschema/autoplace_fields.cpp
> @@ -410,7 +410,10 @@ protected:
> }
>
> if( collision != COLLIDE_NONE )
> - colliding.push_back( (SIDE_AND_COLL){ side, collision } );
> + {
> + SIDE_AND_COLL tmp = { side, collision };
> + colliding.push_back( tmp );
> + }
You can just use
colliding.push_back({ side, collision });
or
colliding.push_back(SIDE_AND_COLL{side, collision});
here. The C++ compiler can deduce the type of the argument from the
container type. Both versions construct an object in-place and allow
the compiler to take advantage of move semantics as far as I can tell.
References