g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
autodiff
memory.h
Go to the documentation of this file.
1
// Copyright 2017 The Abseil Authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
//
15
// -----------------------------------------------------------------------------
16
// File: memory.h
17
// -----------------------------------------------------------------------------
18
//
19
// This header file contains utility functions for managing the creation and
20
// conversion of smart pointers. This file is an extension to the C++
21
// standard <memory> library header file.
22
23
#ifndef G2O_CERES_PUBLIC_INTERNAL_MEMORY_H_
24
#define G2O_CERES_PUBLIC_INTERNAL_MEMORY_H_
25
26
#include <memory>
27
28
#ifdef G2O_CERES_HAVE_EXCEPTIONS
29
#define G2O_CERES_INTERNAL_TRY try
30
#define G2O_CERES_INTERNAL_CATCH_ANY catch (...)
31
#define G2O_CERES_INTERNAL_RETHROW \
32
do { \
33
throw; \
34
} while (false)
35
#else
// G2O_CERES_HAVE_EXCEPTIONS
36
#define G2O_CERES_INTERNAL_TRY if (true)
37
#define G2O_CERES_INTERNAL_CATCH_ANY else if (false)
38
#define G2O_CERES_INTERNAL_RETHROW \
39
do { \
40
} while (false)
41
#endif
// G2O_CERES_HAVE_EXCEPTIONS
42
43
namespace
g2o
{
44
namespace
ceres {
45
namespace
internal
{
46
47
template
<
typename
Allocator,
typename
Iterator,
typename
... Args>
48
void
ConstructRange
(Allocator& alloc, Iterator first, Iterator last,
49
const
Args&... args) {
50
for
(Iterator cur = first; cur != last; ++cur) {
51
G2O_CERES_INTERNAL_TRY
{
52
std::allocator_traits<Allocator>::construct(alloc, std::addressof(*cur),
53
args...);
54
}
55
G2O_CERES_INTERNAL_CATCH_ANY
{
56
while
(cur != first) {
57
--cur;
58
std::allocator_traits<Allocator>::destroy(alloc, std::addressof(*cur));
59
}
60
G2O_CERES_INTERNAL_RETHROW
;
61
}
62
}
63
}
64
65
template
<
typename
Allocator,
typename
Iterator,
typename
InputIterator>
66
void
CopyRange
(Allocator& alloc, Iterator destination, InputIterator first,
67
InputIterator last) {
68
for
(Iterator cur = destination; first != last;
69
static_cast<
void
>
(++cur),
static_cast<
void
>
(++first)) {
70
G2O_CERES_INTERNAL_TRY
{
71
std::allocator_traits<Allocator>::construct(alloc, std::addressof(*cur),
72
*first);
73
}
74
G2O_CERES_INTERNAL_CATCH_ANY
{
75
while
(cur != destination) {
76
--cur;
77
std::allocator_traits<Allocator>::destroy(alloc, std::addressof(*cur));
78
}
79
G2O_CERES_INTERNAL_RETHROW
;
80
}
81
}
82
}
83
84
}
// namespace internal
85
}
// namespace ceres
86
}
// namespace g2o
87
88
#endif
// G2O_CERES_PUBLIC_INTERNAL_MEMORY_H_
G2O_CERES_INTERNAL_RETHROW
#define G2O_CERES_INTERNAL_RETHROW
Definition
memory.h:38
G2O_CERES_INTERNAL_TRY
#define G2O_CERES_INTERNAL_TRY
Definition
memory.h:36
G2O_CERES_INTERNAL_CATCH_ANY
#define G2O_CERES_INTERNAL_CATCH_ANY
Definition
memory.h:37
g2o::ceres::internal::CopyRange
void CopyRange(Allocator &alloc, Iterator destination, InputIterator first, InputIterator last)
Definition
memory.h:66
g2o::ceres::internal::ConstructRange
void ConstructRange(Allocator &alloc, Iterator first, Iterator last, const Args &... args)
Definition
memory.h:48
g2o
Definition
dl_wrapper.cpp:55
internal
Definition
base_variable_sized_edge.hpp:29
Generated on
for g2o by
1.17.0