mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Add [[trivial_abi]] to Detail::unique_ptr when compiled with Clang
This decreases code size and improves performance of passing around `unique_ptr` instances by value somewhat. It virtually guarantees problems when combining code compiled with Clang and GCC, but that was never supported anyway.
This commit is contained in:
parent
eb452e9b35
commit
1d79683ea8
@ -11,13 +11,22 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#if defined(__clang__) && defined(__has_attribute)
|
||||||
|
# if __has_attribute(trivial_abi)
|
||||||
|
# define TRIVIAL_ABI [[clang::trivial_abi]]
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if !defined(TRIVIAL_ABI)
|
||||||
|
# define TRIVIAL_ABI
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
// reimplementation of unique_ptr for improved compilation times
|
// reimplementation of unique_ptr for improved compilation times
|
||||||
// Does not support custom deleters (and thus does not require EBO)
|
// Does not support custom deleters (and thus does not require EBO)
|
||||||
// Does not support arrays
|
// Does not support arrays
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class unique_ptr {
|
class TRIVIAL_ABI unique_ptr {
|
||||||
T* m_ptr;
|
T* m_ptr;
|
||||||
public:
|
public:
|
||||||
constexpr unique_ptr(std::nullptr_t = nullptr):
|
constexpr unique_ptr(std::nullptr_t = nullptr):
|
||||||
|
Loading…
Reference in New Issue
Block a user