MeshLib C++ Docs
Loading...
Searching...
No Matches
MRResizeNoInit.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
MRMeshFwd.h
"
4
#include "
MRMacros.h
"
5
#include <concepts>
6
7
namespace
MR
8
{
9
13
template
<
typename
T>
14
void
resizeNoInit
( std::vector<T> & vec,
size_t
targetSize )
MR_REQUIRES_IF_SUPPORTED
(
sizeof
( T ) > 0 && std::constructible_from<T, NoInit> )
15
{
16
// allocate enough memory
17
vec.reserve( targetSize );
18
// resize without memory access
19
while
( vec.size() < targetSize )
20
vec.emplace_back(
noInit
);
21
// in case initial size was larger
22
vec.resize( targetSize );
23
}
24
25
}
//namespace MR
MRMacros.h
MR_REQUIRES_IF_SUPPORTED
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition
MRMacros.h:31
MRMeshFwd.h
MR
Definition
MRCameraOrientationPlugin.h:8
MR::noInit
constexpr NoInit noInit
Definition
MRMesh/MRMeshFwd.h:91
MR::resizeNoInit
void resizeNoInit(std::vector< T > &vec, size_t targetSize) MR_REQUIRES_IF_SUPPORTED(sizeof(T) > 0 &&std
Definition
MRResizeNoInit.h:14
MeshLib
source
MRMesh
MRResizeNoInit.h
Generated by
1.11.0