-
Notifications
You must be signed in to change notification settings - Fork 107
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
Problems with BOOST_TYPE_ERASURE_MEMBER #345
Comments
It seems that 1.67.0 or later is required. But if you replace them, older boost version could be used. // place them out of mqtt namespace (global namespace)
// BOOST_TYPE_ERASURE_MEMBER((name_space)(has_func_name), func_name, num_of_params)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_async_read), async_read, 3)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_async_write), async_write, 3)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_write), write, 2)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_post), post, 1)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_lowest_layer), lowest_layer, 0)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_close), close, 1) I should update README.md. |
Could you replace and test the following file? type_erased_socket.hpp // Copyright Takatoshi Kondo 2019
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(MQTT_TYPE_ERASED_SOCKET_HPP)
#define MQTT_TYPE_ERASED_SOCKET_HPP
#include <cstdlib>
#include <boost/config/workaround.hpp>
#include <boost/type_erasure/member.hpp>
#include <boost/system/error_code.hpp>
#include <boost/asio.hpp>
#include <mqtt/shared_any.hpp>
#if BOOST_VERSION >= 106700
namespace mqtt {
// New style boost type_erasure member fucntion concept definition
BOOST_TYPE_ERASURE_MEMBER(has_async_read, async_read)
BOOST_TYPE_ERASURE_MEMBER(has_async_write, async_write)
BOOST_TYPE_ERASURE_MEMBER(has_write, write)
BOOST_TYPE_ERASURE_MEMBER(has_post, post)
BOOST_TYPE_ERASURE_MEMBER(has_lowest_layer, lowest_layer)
BOOST_TYPE_ERASURE_MEMBER(has_close, close)
} // namespace mqtt
#else // BOOST_VERSION >= 106700
// Old style boost type_erasure member fucntion concept definition
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_async)_read, async_read, 3)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_async_write), async_write, 3)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_write), write, 2)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_post), post, 1)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_lowest_layer), lowest_layer, 0)
BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_close), close, 1)
#endif // BOOST_VERSION >= 106700
namespace mqtt {
namespace as = boost::asio;
using namespace boost::type_erasure;
/**
* @brief type alias of the type erased socket
* - mqtt::socket is a type erased socket.
* - shared_ptr of any classes that have listed functions (or matching funtion template)
* can be used as the initializer of mqtt::socket.
* - The class template endpoint uses mqtt::socket via listed interface.
* - lowest_layer is provided for users to configure the socket (e.g. set delay, buffer size, etc)
*
*/
using socket = shared_any<
mpl::vector<
destructible<>,
has_async_read<void(as::mutable_buffer, std::function<void(boost::system::error_code const&, std::size_t)>)>,
has_async_write<void(std::vector<as::const_buffer>, std::function<void(boost::system::error_code const&, std::size_t)>)>,
has_write<std::size_t(std::vector<as::const_buffer>, boost::system::error_code&)>,
has_post<void(std::function<void()>)>,
has_lowest_layer<as::basic_socket<as::ip::tcp>&()>,
has_close<void(boost::system::error_code&)>
>
>;
} // namespace mqtt
#endif // MQTT_TYPE_ERASED_SOCKET_HPP |
I tried to do the same earlier. Unfortunately your test file given above results in this error, instead:
I am attempting to upgrade to boost 1.70, which will resolve the problem for me (I think?) But you may still prefer to support boost < 1.67, and I am happy to help investigate that. |
Sorry BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_async)_read, async_read, 3) should be BOOST_TYPE_ERASURE_MEMBER((mqtt)(has_async_read), async_read, 3) Could you try again? |
That appears to fix the first problem!!! Wonderful. Now there's a new problem :-)
|
Could you replace has_lowest_layer<as::basic_socket<as::ip::tcp>&()>, with has_lowest_layer<as::ip::tcp::socket::lowest_layer_type&()>, ? |
That appears to have fixed it! I still have plenty of other compiler errors in my code that i need to fix, but we appear to have fixed the boost 1.67 problem! |
Thank you for checking. I will send a PR to fix the problem you reported. |
Fixed by #347. |
I got the master branch and I encounter the same issue with boost 1.70.0 |
@ropieur , the compile error isn't reproduced on my environment. |
@redboltz,
Output
|
@ropieur , the error message you got is the same as follows ? mqtt_cpp/include/mqtt/type_erased_socket.hpp:23: error: macro "BOOST_PP_SEQ_ELEM_III" requires 2 arguments, but only 1 given |
@redboltz,
|
@ropieur , it is different error from the error first reported. I reproduced the error, see It is caused by pedantic flags. So Boost.TypeErasure new macro seems to use out of standard expansion. I guess you set the flag. Could you try compile without pedantic flag? I know setting pedantic flag is reasonable. |
@redboltz, |
@ropieur , thank you for confirming. Of course, I don't enforce removing pedantic flag. I will send the PR to fix the issue. Please wait a moment. |
I'm currently using Boost 1.65 (It's what my operating system comes with).
I just pulled the newly merged code for #320 and am now seeing this error.
mqtt_cpp/include/mqtt/type_erased_socket.hpp:23: error: macro "BOOST_PP_SEQ_ELEM_III" requires 2 arguments, but only 1 given
BOOST_TYPE_ERASURE_MEMBER(has_async_read, async_read)
^~~~~~~~~~~~~~~~~~~
What version of boost do you consider the minimum required version?
The text was updated successfully, but these errors were encountered: