[Proj] Use of C++
Mateusz Loskot
mateusz at loskot.net
Wed May 23 13:30:16 EST 2018
On 23 May 2018 at 19:59, Andrew Bell <andrew.bell.ia at gmail.com> wrote:
> That said, the issue I have with the GDAL API, which is mentioned as a
> model, is that it's complicated in that it's always unclear who owns what
> and what needs to be freed by the application, etc. It creates bugs and
> ambiguities. Whether the API is C or C++, allowing the library to manage
> data to the extent possible is desirable. Looking at the proj 4 API, there
> are only a few instances where you might need to look at the source code or
> documentation on this (proj_list..., a few calls that take non-const char *
> and a few that take char **), so not a bad starting point.
Since the discussion touches the aspect if/how choice of C++ affects API
discoverability and transparency [1], I'd only point out that costness of
pointer/pointee does not necessarily indicate ownership responsibility.
All three are perfectly delete/free-able:
char const* f1() { return new char{'\a'}; }
char* const f2() { return new char{'\a'}; }
char const* const f3() { return new char{'\a'}; }
Although I'm mostly C++11+ user, I agree with Andrew clean OOP interface
can be achieved using both, C or C++.
(GTK always served me as an excellent example of clean OOP in C.)
Finally, if Even's choice is C++, I'm fairly certain Even will not go
for equivalent
of GDAL's CPL strings, lists, etc. jugglers, but stick to C++ standard library.
[1] https://accu.org/index.php/journals/1572
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
More information about the Proj
mailing list