Re: Any C++20 features you would like to use?

2022-06-20 Thread Stephan Bergmann

On 19/06/2022 07:01, Ilmari Lauhakangas wrote:
Currently our Windows and macOS baselines are leading the pack in terms 
of latest C++ features. Our Linux distro baseline with RHEL/CentOS 7 
provides relatively fresh GCC and Clang versions through extra 
repositories.


GCC 11 in SCL:
https://centos.pkgs.org/7/centos-sclo-rh-x86_64/devtoolset-11-gcc-11.2.1-1.2.el7.x86_64.rpm.html 



llvm 13 in EPEL 7:
https://centos.pkgs.org/7/epel-x86_64/llvm13-13.0.1-1.el7.x86_64.rpm.html


While that devtoolset GCC makes sure to only link against the baseline 
libstdc++, that plain Clang does not AFAIU.  We might need to keep that 
in mind when we use Clang to build external/skia in an otherwise GCC build.




Any C++20 features you would like to use?

2022-06-18 Thread Ilmari Lauhakangas

We recently branched, so it's a good time to think about compiler baselines.

Currently our Windows and macOS baselines are leading the pack in terms 
of latest C++ features. Our Linux distro baseline with RHEL/CentOS 7 
provides relatively fresh GCC and Clang versions through extra repositories.


GCC 11 in SCL:
https://centos.pkgs.org/7/centos-sclo-rh-x86_64/devtoolset-11-gcc-11.2.1-1.2.el7.x86_64.rpm.html

llvm 13 in EPEL 7:
https://centos.pkgs.org/7/epel-x86_64/llvm13-13.0.1-1.el7.x86_64.rpm.html

In the future, probably the biggest pressure for bumpage will be on 
Clang as it is lagging behind the competition in features.


I'm not advocating for any particular bump target, but it would be 
interesting to hear if people have any wishes regarding C++20 features. 
What has so far come up:


- template-parameter-list for generic lambdas 
https://en.cppreference.com/w/cpp/language/lambda#Syntax (available by 
bumping GCC to 8 and Clang to 9)
- std::endian https://en.cppreference.com/w/cpp/types/endian (available 
by bumping GCC to 8)


I got the idea to look at what Boost library features we use and what 
could be replaced by standard features. I don't mean we should aim for 
some wholesale banishment of Boost, but for sure minimising its use has 
various benefits like reduced build times. Cleaner code, easier 
usability and better performance are good reasons to stick with Boost libs.


Command used to discover Boost stuff:
git grep -Eho 'boost::[a-z_:]+' | sort | uniq

Irrelevant stuff like patches in external/boost ignored.

Boost libraries we might want to replace:

- boost::bind http://www.boost.org/libs/bind 
https://en.cppreference.com/w/cpp/utility/functional/bind Already in 
C++11. Has some subtle differences to std::bind, but is only used in 
sdext/source/pdfimport/pdfparse/pdfparse.cxx
- boost::enable_shared_ptr_from_this Only mentioned in obsolete comments 
in slideshow/source/inc/soundplayer.hxx
- boost::filesystem https://www.boost.org/libs/filesystem/doc/index.htm 
https://en.cppreference.com/w/cpp/filesystem Would require GCC 8 (after 
bumping macOS runtime to 10.15 in Jan 2023)
- boost::lexical_cast 
https://www.boost.org/doc/html/boost_lexical_cast.html 
https://en.cppreference.com/w/cpp/utility#Elementary_string_conversions 
Would require GCC 8. Full floating-point support not in any Clang 
version yet, but we use Dragonbox for float-to-string anyway
- boost::optional (::make_optional only used in libetonyek) 
https://www.boost.org/libs/optional 
https://en.cppreference.com/w/cpp/utility/optional 
https://www.cppstories.com/2018/05/using-optional/#migration-from-boostoptional 
C++17, no need to bump anything
- boost::shared_ptr (related ::dynamic_pointer_cast) 
https://www.boost.org/libs/smart_ptr 
https://en.cppreference.com/w/cpp/memory/shared_ptr Already in C++11. 
Used mostly because it is used in libcmis
- boost::starts_with 
https://www.boost.org/doc/libs/release/doc/html/boost/algorithm/starts_with.html 
https://en.cppreference.com/w/cpp/string/basic_string/starts_with Would 
require GCC 9. Used in libcmis
- boost::variant https://www.boost.org/libs/variant 
https://en.cppreference.com/w/cpp/utility/variant 
https://www.cppstories.com/2018/06/variant/#migration-from-boostvariant 
C++17, no compiler bump needed. We just bumped our macOS runtime to 
10.14, so all features related to variant are safe to use


Boost libraries we can revisit when C++23 features become available:

- boost::gregorian and boost::posix_time 
https://www.boost.org/libs/date_time 
https://en.cppreference.com/w/cpp/header/chrono std::chrono might have 
enough features starting from C++20. However, a design issue related to 
formatting is only fixed in C++23 (approved): 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2372r3.html
- Range (::adaptors, ::make_iterator_range) 
https://www.boost.org/libs/range 
https://en.cppreference.com/w/cpp/ranges More fully featured in C++23
- boost::split (used with boost::is_any_of) 
https://www.boost.org/doc/libs/1_79_0/doc/html/boost/algorithm/split.html 
https://en.cppreference.com/w/cpp/ranges/split_view Becomes more robust 
in C++23 (approved): 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2210r2.html


Boost libraries we probably don't want to replace (happy to be proven 
wrong):


- boost::circular_buffer https://www.boost.org/libs/circular_buffer A 
special container with good performance

- boost::container::flat_map Special container for special purpose
- boost::hash https://www.boost.org/libs/container_hash 
https://en.cppreference.com/w/cpp/utility/hash Maybe used for some good 
reason?
- boost::intrusive::circular_list_algorithms 
https://www.boost.org/libs/intrusive Special container for special 
purpose. Used only in sw/inc/ring.hxx
- boost::intrusive_ptr https://www.boost.org/libs/smart_ptr Special 
pointer with no equivalent in STL
- boost::iterator_facade https://www.boost.org/libs/iterator 
https://vector-of-bool.github.io/2020/06