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

Improve MQTT_STD_XXX behavior #929

Merged
merged 6 commits into from
Apr 9, 2022
Merged

Improve MQTT_STD_XXX behavior #929

merged 6 commits into from
Apr 9, 2022

Conversation

Tradias
Copy link
Contributor

@Tradias Tradias commented Apr 8, 2022

What

  • Do not include Boost variations of std::optional and std::any when their respective MQTT_STD_XXX options are set.
  • Do not assume that std::string_view can be constructed from a pair of iterators because that is a C++20 feature.
  • Correctly check for support for std::make_shared<T[]>. See https://en.cppreference.com/w/cpp/feature_test
  • Do not use in retained_topic_map.hpp just to get access to std::endl, use '\n' instead.

Why

Including headers that are not used unnecessarily increases compile times. It is considered good practice to include only what you use.
Enabling the MQTT_STD_XXX options should not assume presence of full C++20 support, otherwise a user's application might not compile even if they are using C++17 with access to such std types.

…n MQTT_STD_XXX option is set.

fix: Do not assume that std::string_view is constructable from a pair of iterators because that requires C++20.
fix: Correctly check for std::make_shared<T[]> support
…in is a fancy iterator. It was also incorrectly calculating the size of the string_view
@codecov
Copy link

codecov bot commented Apr 8, 2022

Codecov Report

Merging #929 (1714248) into master (ae1945a) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #929      +/-   ##
==========================================
- Coverage   83.08%   83.06%   -0.02%     
==========================================
  Files          64       65       +1     
  Lines       10357    10358       +1     
==========================================
- Hits         8605     8604       -1     
- Misses       1752     1754       +2     

include/mqtt/shared_ptr_array.hpp Outdated Show resolved Hide resolved
@@ -358,7 +358,7 @@ class retained_topic_map {
void dump(Output &out) {
auto const& direct_index = map.template get<direct_index_tag>();
for (auto const& i : direct_index) {
out << i.parent_id << " " << i.name << " " << (i.value ? "init" : "-") << " " << i.count << std::endl;
out << i.parent_id << " " << i.name << " " << (i.value ? "init" : "-") << " " << i.count << '\n';
Copy link
Owner

Choose a reason for hiding this comment

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

Why this replacement is needed ? Just avoid include ostream ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, seeing that this is the only use of ostream in this file and this function is a debug function.

@redboltz
Copy link
Owner

redboltz commented Apr 9, 2022

Thanks you for update.

@redboltz redboltz merged commit fa56ace into redboltz:master Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants