Files
cbindgen/tests/expectations/transparent.cpp
T
Emilio Cobos Álvarez b2e224354b Use placement new for constructing in tagged unions' helper methods.
Using operator= is not quite sound in presence of destructors and operator
overloading.

It's perfectly fine to assume that the left-hand-side of an operator= expression
is valid memory, however we're using uninitialized memory here, that may not be
the case.

Use placement new to properly construct tagged unions. I don't need this with
any urgency, but it's the right thing to do in presence of complex types, and
the current code seems a bomb waiting to explode :)
2019-05-10 18:15:39 +02:00

42 lines
1.3 KiB
C++

#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>
struct DummyStruct;
struct EnumWithAssociatedConstantInImpl;
using TransparentComplexWrappingStructTuple = DummyStruct;
using TransparentPrimitiveWrappingStructTuple = uint32_t;
using TransparentComplexWrappingStructure = DummyStruct;
using TransparentPrimitiveWrappingStructure = uint32_t;
template<typename T>
using TransparentComplexWrapper = DummyStruct;
template<typename T>
using TransparentPrimitiveWrapper = uint32_t;
using TransparentPrimitiveWithAssociatedConstants = uint32_t;
static const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ZERO = 0;
static const TransparentPrimitiveWithAssociatedConstants TransparentPrimitiveWithAssociatedConstants_ONE = 1;
static const TransparentPrimitiveWrappingStructure EnumWithAssociatedConstantInImpl_TEN = 10;
extern "C" {
void root(TransparentComplexWrappingStructTuple a,
TransparentPrimitiveWrappingStructTuple b,
TransparentComplexWrappingStructure c,
TransparentPrimitiveWrappingStructure d,
TransparentComplexWrapper<int32_t> e,
TransparentPrimitiveWrapper<int32_t> f,
TransparentPrimitiveWithAssociatedConstants g,
EnumWithAssociatedConstantInImpl h);
} // extern "C"