Latest Posts

Topic: std::optional or boost::optional?

jmoerschbach
Avatar
Topic Opener
Joined: 2019-09-26, 21:40
Posts: 24
Ranking
Pry about Widelands
Posted at: 2020-10-23, 11:26

Hi, in C++17 there is std::optional available, which I think we cannot use because we are still C++11, right?

What about boost::optional as alternative (we are already depending on boost). I repeatedly stumble across code spots where we would like to use an optional but instead are forced to use nullptr or std::numeric_limits<size_t>::max() or sth else to model that something might be there


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2054
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2020-10-23, 11:32

We still use C++11 so no std::optional sadly. Also please try to avoid boost where possible, we rely too much on it in my opinion. I usually use an std::unique_ptr instead, like this: https://github.com/Noordfrees/widelands/blob/multithreading_new/src/base/multithreading.cc#L30


Top Quote
teppo

Joined: 2012-01-30, 09:42
Posts: 424
Ranking
Tribe Member
Posted at: 2020-10-24, 17:24

Nordfriese wrote:

We still use C++11

Why? (edit: Honest question. We are not obliged to support old compilers / operating systems. Widelands switched to C++11 in either 2013 or 2014.)

Edited: 2020-10-24, 17:35

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2054
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2020-10-24, 17:59

teppo wrote:

Nordfriese wrote:

We still use C++11

Why? (edit: Honest question. We are not obliged to support old compilers / operating systems.

Why shouldn't we support older OSs if possible without too much effort?
(Also an honest question. In my opinion, support for older systems is a stronger argument than a bit more convenience for the programmers.)


Top Quote
teppo

Joined: 2012-01-30, 09:42
Posts: 424
Ranking
Tribe Member
Posted at: 2020-10-25, 08:47

Nordfriese wrote:

Why shouldn't we support older OSs if possible without too much effort?
(Also an honest question. In my opinion, support for older systems is a stronger argument than a bit more convenience for the programmers.)

Are there any people developing Widelands using computers that could not have compilers supporting C++17? Are there any people playing Widelands in environments where running a C++17 version would become impossible? I suppose not, but am not certain.

If no real harm is done, we should, in my opinion, upgrade - I think that the convenience of programmers matters, at least if somebody willing to become a coder skips the opportunity because of language version restriction like this. EDIT: I do not feel strong about this, just expressing my opinion.

Edited: 2020-10-25, 09:31

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3317
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2020-10-25, 10:26

Are there any people developing Widelands using computers that could not have compilers supporting C++17?

Probably not

Are there any people playing Widelands in environments where running a C++17 version would become impossible?

Impossible to tell, because we don't have any statistics on this.

We have recently dropped support for gcc 4.8 as Ubuntu Trusty is no longer under official support. We could research the prerequisites for getting a build on a vanilla Xenial and use that as a measuring rod.


Busy indexing nil values

Top Quote
jmoerschbach
Avatar
Topic Opener
Joined: 2019-09-26, 21:40
Posts: 24
Ranking
Pry about Widelands
Posted at: 2020-10-25, 12:55

teppo wrote:

Nordfriese wrote:

Why shouldn't we support older OSs if possible without too much effort?
(Also an honest question. In my opinion, support for older systems is a stronger argument than a bit more convenience for the programmers.)

Are there any people developing Widelands using computers that could not have compilers supporting C++17? Are there any people playing Widelands in environments where running a C++17 version would become impossible? I suppose not, but am not certain.

If no real harm is done, we should, in my opinion, upgrade - I think that the convenience of programmers matters, at least if somebody willing to become a coder skips the opportunity because of language version restriction like this. EDIT: I do not feel strong about this, just expressing my opinion.

+1 from me (and I don't feel too strong about this, neither), but for the sake of code maintenance I would appreciate modern versions of the language we use.

Do we have any metrics/triggers for deciding when to switch to a newer C++ version? Why did we switch to C++11 back in the days and was it painful for anybody? face-wink.png


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3317
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2020-10-25, 13:22

The decision to switch over to C++11 was made just before I joined the team, so I don't know. I was certainly glad to have nullptr, unique_ptr and ranged loops available, and one of my early jobs was to help with code cleanups for the transition. In fact, I am still working on that cleanup on and off years later - with the help of clang-tidy now face-smile.png


Busy indexing nil values

Top Quote
jmoerschbach
Avatar
Topic Opener
Joined: 2019-09-26, 21:40
Posts: 24
Ranking
Pry about Widelands
Posted at: 2020-10-25, 13:34

there is a nice overview:

https://en.cppreference.com/w/cpp/compiler_support/17


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3317
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2020-10-25, 19:49

No std::optional then, because we support GCC5 and we'd need GCC7 for that.


Busy indexing nil values

Top Quote