| 1 |
#define MUST_USE_FUNC __attribute__((warn_unused_result)) |
| 2 |
#define MUST_USE_STRUCT __attribute__((warn_unused)) |
| 3 |
#define MUST_USE_ENUM /* nothing */ |
| 4 |
|
| 5 |
|
| 6 |
#include <cstdarg> |
| 7 |
#include <cstdint> |
| 8 |
#include <cstdlib> |
| 9 |
#include <ostream> |
| 10 |
#include <new> |
| 11 |
|
| 12 |
template<typename T> |
| 13 |
struct MUST_USE_STRUCT MaybeOwnedPtr { |
| 14 |
enum class MUST_USE_ENUM Tag : uint8_t { |
| 15 |
Owned, |
| 16 |
None, |
| 17 |
}; |
| 18 |
|
| 19 |
struct Owned_Body { |
| 20 |
T *_0; |
| 21 |
}; |
| 22 |
|
| 23 |
Tag tag; |
| 24 |
union { |
| 25 |
Owned_Body owned; |
| 26 |
}; |
| 27 |
}; |
| 28 |
|
| 29 |
template<typename T> |
| 30 |
struct MUST_USE_STRUCT OwnedPtr { |
| 31 |
T *ptr; |
| 32 |
}; |
| 33 |
|
| 34 |
extern "C" { |
| 35 |
|
| 36 |
MUST_USE_FUNC MaybeOwnedPtr<int32_t> maybe_consume(OwnedPtr<int32_t> input); |
| 37 |
|
| 38 |
} // extern "C" |