tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
buffer.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_NET_BUFFER_HPP
4#define TETL_NET_BUFFER_HPP
5
6#include <etl/version.hpp>
7
8#include <etl/array.hpp>
9#include <etl/vector.hpp>
10
13
15inline auto make_buffer(void* data, size_t size) noexcept -> mutable_buffer { return mutable_buffer{data, size}; }
16
17inline auto make_buffer(void const* data, size_t size) noexcept -> const_buffer { return const_buffer{data, size}; }
18
19template <typename T, etl::size_t Size>
21{
22 return mutable_buffer{array.data(), array.size()};
23}
24
25template <typename T, etl::size_t Size>
26inline auto make_buffer(etl::array<T, Size> const& array) noexcept -> const_buffer
27{
28 return const_buffer{array.data(), array.size()};
29}
30
31template <typename T, etl::size_t Size>
33{
34 return mutable_buffer{vec.data(), vec.size()};
35}
36
37template <typename T, etl::size_t Size>
38inline auto make_buffer(etl::static_vector<T, Size> const& vec) noexcept -> const_buffer
39{
40 return const_buffer{vec.data(), vec.size()};
41}
42
43} // namespace etl::experimental::net
44
45#endif // TETL_NET_BUFFER_HPP
constexpr auto data(C &c) noexcept(noexcept(c.data())) -> decltype(c.data())
Returns a pointer to the block of memory containing the elements of the container.
Definition data.hpp:11
constexpr auto size(C const &c) noexcept(noexcept(c.size())) -> decltype(c.size())
Returns the size of the given container c or array array. Returns c.size(), converted to the return t...
Definition size.hpp:18
Definition buffer.hpp:14
auto make_buffer(void *data, size_t size) noexcept -> mutable_buffer
Definition buffer.hpp:15
A container that encapsulates fixed size arrays.
Definition array.hpp:48
constexpr auto data() noexcept -> pointer
Returns pointer to the underlying array serving as element storage. The pointer is such that range [d...
Definition array.hpp:99
constexpr auto size() const noexcept -> size_type
Returns the number of elements in the container, i.e. distance(begin(), end()).
Definition array.hpp:196
Definition buffer_const.hpp:12
Definition buffer_mutable.hpp:12
Dynamically-resizable fixed-capacity vector.
Definition static_vector.hpp:329