本文整理汇总了C++中Alloc::construct方法的典型用法代码示例。如果您正苦于以下问题:C++ Alloc::construct方法的具体用法?C++ Alloc::construct怎么用?C++ Alloc::construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alloc
的用法示例。
在下文中一共展示了Alloc::construct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: T
Array1D(int size, bool init = false, T initValue = T()) :
mSize(size) {
Alloc alloc;
mData = alloc.allocate(mSize);
if (init) {
for (int i = 0; i < mSize; ++i) {
alloc.construct(&mData[i], initValue);
}
}
}
示例2: uninitialized_fill_n_with_alloc
inline void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const T& item, Alloc& alloc) {
ForwardIterator next = first;
BOOST_TRY {
for (; n > 0; ++first, --n)
alloc.construct(first, item);
} BOOST_CATCH(...) {
for (; next != first; ++next)
alloc.destroy(next);
BOOST_RETHROW
}
BOOST_CATCH_END
}
示例3: uninitialized_copy_with_alloc
inline ForwardIterator uninitialized_copy_with_alloc(InputIterator first, InputIterator last, ForwardIterator dest,
Alloc& alloc) {
ForwardIterator next = dest;
BOOST_TRY {
for (; first != last; ++first, ++dest)
alloc.construct(dest, *first);
} BOOST_CATCH(...) {
for (; next != dest; ++next)
alloc.destroy(next);
BOOST_RETHROW
}
BOOST_CATCH_END
return dest;
}
示例4:
__AGENCY_ANNOTATION
typename std::enable_if<
has_construct<Alloc,typename std::iterator_traits<Iterator>::pointer, Args...>::value,
Iterator
>::type
construct_each_impl2(Alloc& a, Iterator first, Iterator last, Args&&... args)
{
for(; first != last; ++first)
{
a.construct(&*first, std::forward<Args>(args)...);
}
return first;
} // end construct_each_impl2()
示例5:
void allocator_traits<Alloc>::construct(Alloc& a, T* p, Args&&... args) {
a.construct(p, std::forward<Args>(args)...); //TODO: It may not be implemented!
}