-
-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
6264: hpx::is_trivially_relocatable trait implementation r=hkaiser a=isidorostsa This PR deals with the implementation of the `is_trivially_relocatable` trait. It offers the user an interface to declare their custom class as `trivially_relocatable` using the macro: `HPX_DECLARE_TRIVIALLY_RELOCATABLE(<class name>)` This assumes that trivially_copyable types are also trivially relocatable, following Folly's convention: https://github.com/facebook/folly/blob/ec297b748575e8ab86333899295715e6e85f909d/folly/Traits.h#L542 Co-authored-by: isidorostsa <tsa.isidoros@gmail.com> Co-authored-by: Isidoros <tsa.isidoros@gmail.com>
- Loading branch information
Showing
9 changed files
with
320 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
libs/core/type_support/include/hpx/type_support/is_trivially_relocatable.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2023 Isidoros Tsaousis-Seiras | ||
// | ||
// SPDX-License-Identifier: BSL-1.0 | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#pragma once | ||
|
||
#include <type_traits> | ||
|
||
// Macro to specialize template for given type | ||
#define HPX_DECLARE_TRIVIALLY_RELOCATABLE(T) \ | ||
namespace hpx { \ | ||
template <> \ | ||
struct is_trivially_relocatable<T> : std::true_type \ | ||
{ \ | ||
}; \ | ||
} | ||
|
||
#define HPX_DECLARE_TRIVIALLY_RELOCATABLE_TEMPLATE(T) \ | ||
namespace hpx { \ | ||
template <typename... K> \ | ||
struct is_trivially_relocatable<T<K...>> : std::true_type \ | ||
{ \ | ||
}; \ | ||
} | ||
|
||
#define HPX_DECLARE_TRIVIALLY_RELOCATABLE_TEMPLATE_IF(T, Condition) \ | ||
namespace hpx { \ | ||
template <typename... K> \ | ||
struct is_trivially_relocatable<T<K...>> : Condition<K...> \ | ||
{ \ | ||
}; \ | ||
} | ||
|
||
namespace hpx { | ||
|
||
template <typename T> | ||
// All trivially copyable types are trivially relocatable | ||
// Other types should default to false. | ||
struct is_trivially_relocatable : std::is_trivially_copyable<T> | ||
{ | ||
}; | ||
|
||
template <typename T> | ||
inline constexpr bool is_trivially_relocatable_v = | ||
is_trivially_relocatable<T>::value; | ||
} // namespace hpx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.