MCPcopy Create free account
hub / github.com/pybind/pybind11 / is_inline

Function is_inline

include/pybind11/detail/argument_vector.h:111–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109 }
110
111 bool is_inline() const {
112 // It is undefined behavior to access the inactive member of a
113 // union directly. However, it is well-defined to reinterpret_cast any
114 // pointer into a pointer to char and examine it as an array
115 // of bytes. See
116 // https://dev-discuss.pytorch.org/t/unionizing-for-profit-how-to-exploit-the-power-of-unions-in-c/444#the-memcpy-loophole-4
117 bool result = false;
118 static_assert(offsetof(inline_array, is_inline) == 0,
119 "untagged union implementation relies on this");
120 static_assert(offsetof(heap_vector, is_inline) == 0,
121 "untagged union implementation relies on this");
122 std::memcpy(&result, reinterpret_cast<const char *>(this), sizeof(bool));
123 return result;
124 }
125};
126
127template <typename T, std::size_t InlineSize>

Callers 14

~inline_array_or_vectorFunction · 0.85
inline_array_or_vectorFunction · 0.85
argument_vector.hFile · 0.85
sizeMethod · 0.85
dataMethod · 0.85
small_vectorClass · 0.85
emplace_backMethod · 0.85
reserveMethod · 0.85
sizeMethod · 0.85
reserveMethod · 0.85
operator[]Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected