Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 31 commits into from
Aug 9, 2024

Conversation

ruslan-ilesik
Copy link
Contributor

@ruslan-ilesik ruslan-ilesik commented Jul 18, 2024

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

  • I have ensured that all methods and functions are fully documented using doxygen style comments.
  • My code follows the coding style guide.
  • I tested that my change works before raising the PR.
  • I have ensured that I did not break any existing API calls.
  • I have not built my pull request using AI, a static analysis tool or similar without any human oversight.

Copy link

netlify bot commented Jul 18, 2024

Deploy Preview for dpp-dev ready!

Name Link
🔨 Latest commit bc01f2f
🔍 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.

@github-actions github-actions bot added documentation Improvements or additions to documentation code Improvements or additions to code. labels Jul 18, 2024
include/dpp/snowflake.h Outdated Show resolved Hide resolved
src/unittest/test.cpp Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
include/dpp/snowflake.h Outdated Show resolved Hide resolved
include/dpp/snowflake.h Outdated Show resolved Hide resolved
@Henonicks
Copy link
Contributor

Henonicks commented Jul 19, 2024

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

@ruslan-ilesik
Copy link
Contributor Author

ruslan-ilesik commented Jul 20, 2024

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.

CMakeLists.txt Outdated Show resolved Hide resolved
Copy link
Contributor

@braindigitalis braindigitalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theres a massive problem with this!
If cmake detects that C++20 is available it will always enable std::format. This means the user is forced to use -std=c++20 for all their bots, even where they dont want to use C++20. This fundamentally breaks compatibility.
Nothing tells the user they must use C++20 anywhere, and furthermore, if they have a need for C++17 they simply cannot ever use C++17 any more.

@ruslan-ilesik
Copy link
Contributor Author

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.

Copy link
Contributor

@Jaskowicz1 Jaskowicz1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with it but need to see what @braindigitalis thinks about the autoconfig.h idea.

@ruslan-ilesik
Copy link
Contributor Author

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

@braindigitalis braindigitalis merged commit 5e5ee60 into brainboxdotcc:dev Aug 9, 2024
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Improvements or additions to code. documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants