lfreist / hwinfo

cross platform C++ library for hardware information (CPU, RAM, GPU, ...)
MIT License
438 stars 76 forks source link

Reduces the C++ standard requirement from 20 to 17 #28

Closed facug91 closed 1 year ago

facug91 commented 1 year ago

I found the library really useful, but I need it to work with an old compiler, which doesn't have C++20 support. I couldn't test it for Windows or Apple, but it works with Ubuntu.
Perhaps it is supposed to work only with C++20, but just in case, I'm making this PR in case somebody else find it convenient.
In addition, file platform.h may not be the best place to put the new function starts_with, I could move it to other location if needed.

lfreist commented 1 year ago

Hi and thanks for contributing. I think, supporting previous C++ standards is worth on a library like this. I will evaluate whether to lower the C++ standard in general or to add another branch for other standards... Not sure what's the best way yet.

However, since (so far) only the std::string::ends_with is C++20 specific it is worth using your implementation instead.

The function should be placed in include/hwinfo/utils/stringutils.h. Also please make sure the clang style test passes (c.f. GitHub actions).

facug91 commented 1 year ago

Hi Leon Thank you for the quick response. I moved the function to include/hwinfo/utils/stringutils.h, fixed the clang styling, and this merge also fixed one tiny error in the CMakeLists.txt where CMAKE_CXX_STANDARD_REQUIRED was incorrectly set to a number, instead of a boolean.