2020-01-18 03:38:21 -05:00
|
|
|
/*
|
2024-10-04 07:19:50 -04:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2020-01-18 03:38:21 -05:00
|
|
|
*
|
2021-04-22 04:24:48 -04:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 03:38:21 -05:00
|
|
|
*/
|
|
|
|
|
2018-12-03 18:27:16 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define AK_MAKE_NONCOPYABLE(c) \
|
2019-05-28 05:53:16 -04:00
|
|
|
private: \
|
2022-04-01 13:58:27 -04:00
|
|
|
c(c const&) = delete; \
|
|
|
|
c& operator=(c const&) = delete
|
2019-09-21 18:17:29 -04:00
|
|
|
|
|
|
|
#define AK_MAKE_NONMOVABLE(c) \
|
2020-08-26 15:52:24 -04:00
|
|
|
private: \
|
|
|
|
c(c&&) = delete; \
|
|
|
|
c& operator=(c&&) = delete
|
2023-06-16 09:56:20 -04:00
|
|
|
|
|
|
|
#define AK_MAKE_DEFAULT_MOVABLE(c) \
|
|
|
|
public: \
|
|
|
|
c(c&&) = default; \
|
|
|
|
c& operator=(c&&) = default
|
2023-10-10 20:48:56 -04:00
|
|
|
|
|
|
|
#define AK_MAKE_DEFAULT_COPYABLE(c) \
|
|
|
|
public: \
|
|
|
|
c(c const&) = default; \
|
|
|
|
c& operator=(c const&) = default
|
2024-10-30 08:44:20 -04:00
|
|
|
|
|
|
|
#define AK_MAKE_CONDITIONALLY_NONMOVABLE(c, ...) \
|
|
|
|
public: \
|
|
|
|
c(c&&) \
|
|
|
|
requires(!(AK::Detail::IsMoveConstructible __VA_ARGS__)) \
|
|
|
|
= delete; \
|
|
|
|
c& operator=(c&&) \
|
|
|
|
requires(!(AK::Detail::IsMoveConstructible __VA_ARGS__) \
|
|
|
|
|| !(AK::Detail::IsDestructible __VA_ARGS__)) \
|
|
|
|
= delete
|
|
|
|
|
|
|
|
#define AK_MAKE_CONDITIONALLY_MOVABLE(c, T) \
|
|
|
|
AK_MAKE_CONDITIONALLY_NONMOVABLE(c, T); \
|
|
|
|
c(c&&) = default; \
|
|
|
|
c& operator=(c&&) = default
|
|
|
|
|
|
|
|
#define AK_MAKE_CONDITIONALLY_NONCOPYABLE(c, ...) \
|
|
|
|
public: \
|
|
|
|
c(c const&) \
|
|
|
|
requires(!(AK::Detail::IsCopyConstructible __VA_ARGS__)) \
|
|
|
|
= delete; \
|
|
|
|
c& operator=(c const&) \
|
|
|
|
requires(!(AK::Detail::IsCopyConstructible __VA_ARGS__) \
|
|
|
|
|| !(AK::Detail::IsDestructible __VA_ARGS__)) \
|
|
|
|
= delete
|
|
|
|
|
|
|
|
#define AK_MAKE_CONDITIONALLY_COPYABLE(c, ...) \
|
|
|
|
AK_MAKE_CONDITIONALLY_NONCOPYABLE(c, __VA_ARGS__); \
|
|
|
|
c(c const&) = default; \
|
|
|
|
c& operator=(c const&) = default
|
|
|
|
|
|
|
|
#define AK_MAKE_CONDITIONALLY_NONDESTRUCTIBLE(c, ...) \
|
|
|
|
public: \
|
|
|
|
~c() \
|
|
|
|
requires(!(AK::Detail::IsDestructible __VA_ARGS__)) \
|
|
|
|
= delete
|
|
|
|
|
|
|
|
#define AK_MAKE_CONDITIONALLY_DESTRUCTIBLE(c, ...) \
|
|
|
|
public: \
|
|
|
|
~c() \
|
|
|
|
requires(!(AK::Detail::IsDestructible __VA_ARGS__)) \
|
|
|
|
= delete; \
|
|
|
|
~c() = default
|