Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use cpp17 and no need for Boost if you disable examples. #284

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

Open
TheSharpOwl wants to merge 13 commits into mfontanini:master
base: master
Choose a base branch
Loading
from TheSharpOwl:use-cpp17

Conversation

@TheSharpOwl
Copy link

@TheSharpOwl TheSharpOwl commented Aug 5, 2021

I replaced the boost::optional and boost::any with C++17 ones (project is set to use C++17). However, examples still use boost and I have no idea yet how to refactor that. Why I did it ? To save space if someone just wants to install the library.

dfleury2 and cclinet reacted with thumbs up emoji
@TheSharpOwl TheSharpOwl changed the title (削除) Use cpp17 and no need for boost if you disable examples. (削除ここまで) (追記) Use cpp17 and no need for Boost if you disable examples. (追記ここまで) Aug 5, 2021
Copy link
Author

I replaced the boost::optional and boost::any with C++17 ones (project is set to use C++17). However, examples still use boost and I have no idea yet how to refactor that. Why I did it ? To save space if someone just wants to install the library.

Edit: if you don't want to break compatibility, I am planning to add which C++ to use for example so that it would be available in old way or new one ?

Copy link
Owner

Given this is quite the breaking change, it should be an optional feature that we can eventually enable by default in say version 1.0. Using std::optional is nice but it will break any existing user's codes, plus it involves them using a newer standard (which is reasonable given C++17 is 4 years old, but still).

Could you turn this into a configurable option? e.g. cmake -DUSE_STD_OPTIONAL and have some header that defines cppkafka::optional to be std::optional or boost::optional depending on it and using cppkafka::optional internally rather than the concrete optional type we're using?

Copy link
Author

Sure then I will do it and let you know)) Thanks.

mfontanini reacted with thumbs up emoji

Copy link
Author

TheSharpOwl commented Aug 10, 2021
edited
Loading

I did it and if someone wants to use only C++17 without any boost, they should do this:
cmake -DUSE_CPP17=ON -DCPPKAFKA_DISABLE_EXAMPLES=ON -DCPPKAFKA_DISABLE_TESTS=ON "DIR"
Also, I fixed some conflicts with max and min on windows so I fixed them. @mfontanini


if(USE_CPP17)
set(CMAKE_CXX_STANDARD 17)
add_definitions("-D_USE_CPP17")
Copy link
Owner

@mfontanini mfontanini Aug 15, 2021

Choose a reason for hiding this comment

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

I don't think this is enough. There needs to be a record somewhere (e.g. in a generated header file) that stores this and code should include that file to figure out this flag.

If you don't do that, you can have the library being compiled with this flag on but an application that uses the library not knowing (for obvious reasons) that they need to set this macro manually, which will break badly because from one's perspective you're using std types and from the other's boost ones.

*/

#ifdef _WIN32
#define NOMINMAX
Copy link
Owner

@mfontanini mfontanini Aug 15, 2021

Choose a reason for hiding this comment

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

This should probably be set as a definition at the cmake level if it's needed, rather than here in this particular file

const Buffer& key = message.get_key();
const int policy = static_cast<int>(message_payload_policy_);
#ifdef _USE_CPP17
int64_t duration = message.get_timestamp() ? message.get_timestamp().value().get_timestamp().count() : 0;
Copy link
Owner

@mfontanini mfontanini Aug 15, 2021

Choose a reason for hiding this comment

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

I presume both optionals have operator* so rather than doing this you can maybe use that which should make the same expression work for both types?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mfontanini mfontanini mfontanini left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /