-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compilation with C++11 and above #10
Conversation
While I was at it, I also fixed |
Thanks, I am looking into it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, thanks
@bubnikv good. Strange indeed that it compiled on VS2013. The compiler there might have different logic for overload resolution. If you happen to figure out a better way to resolve this ambiguity, please enlighten me too :) |
There were several problems in the C++11 and above specific code that prevented compilation with
gcc >= 6.1
where C++14 is used as the default standard instead of C++98 (previousgcc
versions).In
ExPolygon.cpp
andSurface.hpp
there are trivial fixes to typos in the C++11 specific code.In
PolylineCollection
there was an ambiguity between overloaded functions withPolylines &&src
andPolylines src
arguments. In such a situation the compiler can't resolve between those two functions.My attempt at a solution is to make a new private _chained_path_from functions which allows explicitly specifying whether the
Polyline
objects from theconst Polylines &src
vector can be moved. In the public interface, there are overloads ofchained_path
andchained_path_from
functions with const lvalue reference (const Polylines &src
) and rvalue reference (Polylines &&src
) parameters. These call_chained_path_from
respectively asking either to move or not to move fromsrc
. A user of thePolylineCollection
can trigger the move variant by passing an rvalue reference (usingstd::move
).This solution might need some reviewing as I'm still not entirely comfortable with move semantics. In particular, I'm not sure if there could be some other way to trigger the
std::move
in_chained_path_from
without specifying it explicitly (i.e. based on whether the input value isconst Polylines &
orPolylines &&
). Of course one could just do two overloaded variants ofchained_path_from
, but there would be a difference of only one line and that sounds like unnecessary duplication.