brainboxdotcc / DPP

C++ Discord API Bot Library - D++ is Lightweight and scalable for small and huge bots!
https://dpp.dev/
Apache License 2.0
1.05k stars 159 forks source link

feat: std::format support for dpp::snowflake #1203

Closed ruslan-ilesik closed 1 month ago

ruslan-ilesik commented 1 month ago

This pr adds std::format support for dpp::snowflake, if we do not have c++20 or have no include for it will be automatically disabled for compilation.

Test case was implemented to check formatting.

Code change checklist

netlify[bot] commented 1 month ago

Deploy Preview for dpp-dev ready!

Name Link
Latest commit bc01f2f981264446d095c1daad1451947bdc13a9
Latest deploy log https://app.netlify.com/sites/dpp-dev/deploys/66af6403ef8ab6000889141f
Deploy Preview https://deploy-preview-1203--dpp-dev.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Henonicks commented 1 month ago

tested this on Windows and got snowflake: std::format support PASS at the end

ruslan-ilesik commented 1 month ago

So with last commit i have introduced usage of Cmake feature called configure_file which allows us autogenerate headers with some definitions when build dpp, this way we can remove need to define DPP_HAS_FORMAT as it will be defined in it when compiling it.

In theory same way we can eliminate need to specify -DDPP_CORO when compiling bot with dpp with coro enabled in lib.

ruslan-ilesik commented 1 month ago

If lib is build with c++20 then ye, bots will be required to use c++20, I can easily fix it by wrapping cmake define into check of c++ version.

ruslan-ilesik commented 1 month ago

I have tested changes locally on my wsl2 (ubuntu) and tests passed, also compiling bot with -DPP_FORMATTERS and without had required behavior