Main MRPT website
>
C++ reference for MRPT 1.9.9
mrpt
containers
copy_container_typecasting.h
Go to the documentation of this file.
1
/* +------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6
| See: http://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See details in http://www.mrpt.org/License |
8
+------------------------------------------------------------------------+ */
9
#pragma once
10
11
namespace
mrpt
12
{
13
namespace
containers
14
{
15
/** \addtogroup containers_grp
16
* @{ */
17
18
/** Copy all the elements in a container (vector, deque, list) into a different
19
* one performing the appropriate typecasting.
20
* The target container is automatically resized to the appropriate size, and
21
* previous contents are lost.
22
* This can be used to assign std::vector's of different types:
23
* \code
24
* std::vector<int> vi(10);
25
* std::vector<float> vf;
26
* vf = vi; // Compiler error
27
* mrpt::containers::copy_container_typecasting(v1,vf); // Ok
28
* \endcode
29
*/
30
template
<
typename
src_container,
typename
dst_container>
31
inline
void
copy_container_typecasting
(
32
const
src_container&
src
, dst_container& trg)
33
{
34
trg.resize(
src
.size());
35
typename
src_container::const_iterator
i =
src
.begin();
36
typename
src_container::const_iterator
last =
src
.end();
37
typename
dst_container::iterator
target = trg.begin();
38
for
(; i != last; ++i, ++target)
39
*target =
static_cast<
typename dst_container::value_type
>
(*i);
40
}
41
/** @} */
// end of grouping
42
}
// End of namespace
43
}
// end of namespace
const_iterator
const Scalar * const_iterator
Definition:
eigen_plugins.h:27
mrpt::containers::copy_container_typecasting
void copy_container_typecasting(const src_container &src, dst_container &trg)
Copy all the elements in a container (vector, deque, list) into a different one performing the approp...
Definition:
copy_container_typecasting.h:31
src
GLuint src
Definition:
glext.h:7278
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition:
CKalmanFilterCapable.h:30
iterator
Scalar * iterator
Definition:
eigen_plugins.h:26
Page generated by
Doxygen 1.8.17
for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST