Realistic 3D camera system
3D camera system components
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
asio-1.10.6
include
asio
detail
buffer_resize_guard.hpp
Go to the documentation of this file.
1
//
2
// detail/buffer_resize_guard.hpp
3
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
//
5
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6
//
7
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
//
10
11
#ifndef ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP
12
#define ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP
13
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15
# pragma once
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18
#include "
asio/detail/config.hpp
"
19
#include "
asio/detail/limits.hpp
"
20
21
#include "
asio/detail/push_options.hpp
"
22
23
namespace
asio
{
24
namespace
detail {
25
26
// Helper class to manage buffer resizing in an exception safe way.
27
template
<
typename
Buffer>
28
class
buffer_resize_guard
29
{
30
public
:
31
// Constructor.
32
buffer_resize_guard
(Buffer&
buffer
)
33
: buffer_(buffer),
34
old_size_(buffer.size())
35
{
36
}
37
38
// Destructor rolls back the buffer resize unless commit was called.
39
~buffer_resize_guard
()
40
{
41
if
(old_size_ != (std::numeric_limits<size_t>::max)())
42
{
43
buffer_.resize(old_size_);
44
}
45
}
46
47
// Commit the resize transaction.
48
void
commit
()
49
{
50
old_size_ = (std::numeric_limits<size_t>::max)();
51
}
52
53
private
:
54
// The buffer being managed.
55
Buffer& buffer_;
56
57
// The size of the buffer at the time the guard was constructed.
58
size_t
old_size_;
59
};
60
61
}
// namespace detail
62
}
// namespace asio
63
64
#include "
asio/detail/pop_options.hpp
"
65
66
#endif // ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP
asio::detail::buffer_resize_guard::~buffer_resize_guard
~buffer_resize_guard()
Definition:
buffer_resize_guard.hpp:39
asio::detail::buffer_resize_guard::commit
void commit()
Definition:
buffer_resize_guard.hpp:48
asio::buffer
mutable_buffers_1 buffer(const mutable_buffer &b)
Create a new modifiable buffer from an existing buffer.
Definition:
buffer.hpp:706
limits.hpp
config.hpp
push_options.hpp
asio::detail::buffer_resize_guard
Definition:
buffer_resize_guard.hpp:28
pop_options.hpp
asio::detail::buffer_resize_guard::buffer_resize_guard
buffer_resize_guard(Buffer &buffer)
Definition:
buffer_resize_guard.hpp:32
asio
Definition:
async_result.hpp:23
Generated by
1.8.11