Browse Source

Add a NoAllocate tag.

Will be used by Vulkan.
pull/234/head
Vladimír Vondruš 6 years ago
parent
commit
cc9c71f601
  1. 2
      doc/changelog.dox
  2. 23
      src/Magnum/Tags.h
  3. 2
      src/Magnum/Test/TagsTest.cpp

2
doc/changelog.dox

@ -40,6 +40,8 @@ See also:
@subsection changelog-latest-new New features
- New @ref NoAllocate constructor tag, to be used by the @ref Vk library
@subsubsection changelog-latest-new-debugtools DebugTools library
- Added @ref DebugTools::ColorMap::coolWarmSmooth() and

23
src/Magnum/Tags.h

@ -53,6 +53,21 @@ Vulkan / ... object.
*/
typedef Corrade::Containers::NoCreateT NoCreateT;
/**
@brief No allocation tag type
@m_since_latest
Used to distinguish construction without allocating memory.
@see @ref NoAllocate
*/
/* Explicit constructor to avoid ambiguous calls when using {} */
struct NoAllocateT {
#ifndef DOXYGEN_GENERATING_OUTPUT
struct Init{};
constexpr explicit NoAllocateT(Init) {}
#endif
};
/**
@brief No initialization tag
@m_since{2020,06}
@ -80,6 +95,14 @@ constexpr NoCreateT NoCreate{};
using Corrade::Containers::NoCreate;
#endif
/**
@brief No allocation tag
@m_since_latest
Use for construction without allocating memory.
*/
constexpr NoAllocateT NoAllocate{NoAllocateT::Init{}};
}
#endif

2
src/Magnum/Test/TagsTest.cpp

@ -45,11 +45,13 @@ TagsTest::TagsTest() {
void TagsTest::noDefaultConstructor() {
CORRADE_VERIFY(!std::is_default_constructible<NoInitT>::value);
CORRADE_VERIFY(!std::is_default_constructible<NoCreateT>::value);
CORRADE_VERIFY(!std::is_default_constructible<NoAllocateT>::value);
}
void TagsTest::inlineDefinition() {
CORRADE_VERIFY((std::is_same<decltype(NoInit), const NoInitT>::value));
CORRADE_VERIFY((std::is_same<decltype(NoCreate), const NoCreateT>::value));
CORRADE_VERIFY((std::is_same<decltype(NoAllocate), const NoAllocateT>::value));
}
}}}

Loading…
Cancel
Save