mqtt_cpp
include
mqtt
size_util.hpp
Go to the documentation of this file.
1
// Copyright Takatoshi Kondo 2020
2
//
3
// Distributed under the Boost Software License, Version 1.0.
4
// (See accompanying file LICENSE_1_0.txt or copy at
5
// http://www.boost.org/LICENSE_1_0.txt)
6
7
#if !defined(MQTT_SIZE_UTIL_HPP)
8
#define MQTT_SIZE_UTIL_HPP
9
10
#include <
mqtt/config.hpp
>
11
12
#include <limits>
13
#include <utility>
14
15
#include <boost/assert.hpp>
16
17
#include <
mqtt/namespace.hpp
>
18
#include <
mqtt/type.hpp
>
19
20
namespace
MQTT_NS
{
21
22
template
<
typename
T>
23
typename
std::enable_if<
24
sizeof
(
typename
T::value_type) <=
sizeof
(variable_integer_t),
25
variable_integer_t
26
>::type
27
get_size
(T
const
& t) {
28
return
t.size();
29
}
30
31
template
<
typename
T>
32
typename
std::enable_if<
33
! (
sizeof
(
typename
T::value_type) <=
sizeof
(variable_integer_t)),
34
variable_integer_t
35
>::type
36
get_size
(T
const
& t) {
37
BOOST_ASSERT(t.size() <= std::numeric_limits<variable_integer_t>::max());
38
return
t.size(t.size());
39
}
40
41
}
// namespace MQTT_NS
42
43
#endif
// MQTT_SIZE_UTIL_HPP
config.hpp
MQTT_NS
Definition:
any.hpp:27
MQTT_NS::get_size
std::size_t get_size(as::const_buffer const &cb)
Definition:
const_buffer_util.hpp:21
namespace.hpp
type.hpp
Generated by
1.9.1