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

Use an explicit template parameter instead of enable_if #183

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 66 additions & 95 deletions include/mqtt/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2469,17 +2469,15 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
packet_id_t
>::type
async_subscribe(
template <typename Arg0, typename... Args>
packet_id_t async_subscribe(
std::string const& topic_name,
std::uint8_t qos, Args&&... args) {
std::uint8_t qos,
Arg0&& arg0,
Args&&... args) {
BOOST_ASSERT(qos == qos::at_most_once || qos::at_least_once || qos::exactly_once);
packet_id_t packet_id = acquire_unique_packet_id();
acquired_async_subscribe(packet_id, topic_name, qos, std::forward<Args>(args)...);
acquired_async_subscribe(packet_id, topic_name, qos, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
return packet_id;
}

Expand All @@ -2497,17 +2495,15 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
packet_id_t
>::type
async_subscribe(
template <typename Arg0, typename... Args>
packet_id_t async_subscribe(
as::const_buffer const& topic_name,
std::uint8_t qos, Args&&... args) {
std::uint8_t qos,
Arg0&& arg0,
Args&&... args) {
BOOST_ASSERT(qos == qos::at_most_once || qos::at_least_once || qos::exactly_once);
packet_id_t packet_id = acquire_unique_packet_id();
acquired_async_subscribe(packet_id, topic_name, qos, std::forward<Args>(args)...);
acquired_async_subscribe(packet_id, topic_name, qos, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
return packet_id;
}

Expand Down Expand Up @@ -2601,16 +2597,13 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
packet_id_t
>::type
async_unsubscribe(
template <typename Arg0, typename... Args>
packet_id_t async_unsubscribe(
std::string const& topic_name,
Arg0&& arg0,
Args&&... args) {
packet_id_t packet_id = acquire_unique_packet_id();
acquired_async_unsubscribe(packet_id, topic_name, std::forward<Args>(args)...);
acquired_async_unsubscribe(packet_id, topic_name, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
return packet_id;
}

Expand All @@ -2626,16 +2619,13 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
packet_id_t
>::type
async_unsubscribe(
template <typename Arg0, typename... Args>
packet_id_t async_unsubscribe(
as::const_buffer const& topic_name,
Arg0&& arg0,
Args&&... args) {
packet_id_t packet_id = acquire_unique_packet_id();
acquired_async_unsubscribe(packet_id, topic_name, std::forward<Args>(args)...);
acquired_async_unsubscribe(packet_id, topic_name, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
return packet_id;
}

Expand Down Expand Up @@ -2999,18 +2989,16 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066<BR>
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
bool
>::type
async_subscribe(
template <typename Arg0, typename... Args>
bool async_subscribe(
packet_id_t packet_id,
std::string const& topic_name,
std::uint8_t qos, Args&&... args) {
std::uint8_t qos,
Arg0&& arg0,
Args&&... args) {
BOOST_ASSERT(qos == qos::at_most_once || qos::at_least_once || qos::exactly_once);
if (register_packet_id(packet_id)) {
acquired_async_subscribe(packet_id, topic_name, qos, std::forward<Args>(args)...);
acquired_async_subscribe(packet_id, topic_name, qos, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
return true;
}
return false;
Expand All @@ -3031,18 +3019,16 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066<BR>
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
bool
>::type
async_subscribe(
template <typename Arg0, typename... Args>
bool async_subscribe(
packet_id_t packet_id,
as::const_buffer const& topic_name,
std::uint8_t qos, Args&&... args) {
std::uint8_t qos,
Arg0&& arg0,
Args&&... args) {
BOOST_ASSERT(qos == qos::at_most_once || qos::at_least_once || qos::exactly_once);
if (register_packet_id(packet_id)) {
acquired_async_subscribe(packet_id, topic_name, qos, std::forward<Args>(args)...);
acquired_async_subscribe(packet_id, topic_name, qos, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
return true;
}
return false;
Expand Down Expand Up @@ -3160,17 +3146,14 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
bool
>::type
async_unsubscribe(
template <typename Arg0, typename... Args>
bool async_unsubscribe(
packet_id_t packet_id,
std::string const& topic_name,
Arg0&& arg0,
Args&&... args) {
if (register_packet_id(packet_id)) {
acquired_async_unsubscribe(packet_id, topic_name, std::forward<Args>(args)...);
acquired_async_unsubscribe(packet_id, topic_name, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
return true;
}
return false;
Expand All @@ -3190,17 +3173,14 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
bool
>::type
async_unsubscribe(
template <typename Arg0, typename... Args>
bool async_unsubscribe(
packet_id_t packet_id,
as::const_buffer const& topic_name,
Arg0&& arg0,
Args&&... args) {
if (register_packet_id(packet_id)) {
acquired_async_unsubscribe(packet_id, topic_name, std::forward<Args>(args)...);
acquired_async_unsubscribe(packet_id, topic_name, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
return true;
}
return false;
Expand Down Expand Up @@ -3587,17 +3567,15 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066<BR>
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
void
>::type
acquired_async_subscribe(
template <typename Arg0, typename... Args>
void acquired_async_subscribe(
packet_id_t packet_id,
std::string const& topic_name,
std::uint8_t qos, Args&&... args) {
std::uint8_t qos,
Arg0&& arg0,
Args&&... args) {
BOOST_ASSERT(qos == qos::at_most_once || qos::at_least_once || qos::exactly_once);
return acquired_async_subscribe_imp(packet_id, topic_name, qos, std::forward<Args>(args)...);
acquired_async_subscribe_imp(packet_id, topic_name, qos, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
}

/**
Expand All @@ -3615,17 +3593,15 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066<BR>
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0,
void
>::type
acquired_async_subscribe(
template <typename Arg0, typename... Args>
void acquired_async_subscribe(
packet_id_t packet_id,
as::const_buffer const& topic_name,
std::uint8_t qos, Args&&... args) {
std::uint8_t qos,
Arg0&& arg0,
Args&&... args) {
BOOST_ASSERT(qos == qos::at_most_once || qos::at_least_once || qos::exactly_once);
return acquired_async_subscribe_imp(packet_id, topic_name, qos, std::forward<Args>(args)...);
acquired_async_subscribe_imp(packet_id, topic_name, qos, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
}

/**
Expand Down Expand Up @@ -3768,15 +3744,13 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0
>::type
acquired_async_unsubscribe(
template <typename Arg0, typename... Args>
void acquired_async_unsubscribe(
packet_id_t packet_id,
std::string const& topic_name,
Arg0&& arg0,
Args&&... args) {
acquired_async_unsubscribe_imp(packet_id, topic_name, std::forward<Args>(args)...);
acquired_async_unsubscribe_imp(packet_id, topic_name, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
}

/**
Expand All @@ -3791,15 +3765,13 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* You can subscribe multiple topics all at once.<BR>
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718066
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0
>::type
acquired_async_unsubscribe(
template <typename Arg0, typename... Args>
void acquired_async_unsubscribe(
packet_id_t packet_id,
as::const_buffer const& topic_name,
Arg0&& arg0,
Args&&... args) {
acquired_async_unsubscribe_imp(packet_id, topic_name, std::forward<Args>(args)...);
acquired_async_unsubscribe_imp(packet_id, topic_name, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
}

/**
Expand Down Expand Up @@ -3957,15 +3929,14 @@ class endpoint : public std::enable_shared_from_this<endpoint<Socket, Mutex, Loc
* and the last one is a callback function that is called when async operation will finish.
* See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718068
*/
template <typename... Args>
typename std::enable_if<
sizeof...(Args) != 0
>::type
async_suback(
template <typename Arg0, typename... Args>
void async_suback(
packet_id_t packet_id,
std::uint8_t qos, Args&&... args) {
std::uint8_t qos,
Arg0&& arg0,
Args&&... args) {
BOOST_ASSERT(qos == qos::at_most_once || qos::at_least_once || qos::exactly_once);
async_suback_imp(packet_id, qos, std::forward<Args>(args)...);
async_suback_imp(packet_id, qos, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
}

/**
Expand Down