KaMPIng 0.2.1
(Near) zero-overhead MPI wrapper for C++
Loading...
Searching...
No Matches
trivially_copyable.hpp
1// This file is part of KaMPIng.
2//
3// Copyright 2024 The KaMPIng Authors
4//
5// KaMPIng is free software : you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
7// version. KaMPIng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
8// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
9// for more details.
10//
11// You should have received a copy of the GNU Lesser General Public License along with KaMPIng. If not, see
12// <https://www.gnu.org/licenses/>.
13//
14#pragma once
15
16#include <type_traits>
17
21
22namespace kamping::types {
23
24/// @addtogroup kamping_types
25/// @{
26
27/// @brief Opt-in catch-all specialization of \ref kamping::types::mpi_type_traits for any
28/// trivially copyable type not already covered by the built-in dispatcher.
29///
30/// Represents the object as a flat sequence of `sizeof(T)` bytes using `MPI_BYTE`.
31///
32/// `std::pair` and `std::tuple` are excluded so this header composes safely with
33/// \ref kamping/types/std/utility.hpp, \ref kamping/types/std/tuple.hpp, and their unsafe
34/// counterparts — include whichever combination suits your use case.
35///
36/// @warning Padding bytes between fields are silently included in the byte representation.
37/// This is correct for tightly-packed structs, but incorrect for structs with
38/// compiler-inserted padding holes. Users opt in to this trade-off knowingly by
39/// including this header.
40template <typename T>
42 T,
44 std::is_trivially_copyable<T>::value
45 && !has_auto_dispatched_type_v<T> && !kamping::internal::is_std_pair<T>::value
46 && !kamping::internal::is_std_tuple<T>::value>> : byte_serialized<T> {};
47
48/// @}
49
50} // namespace kamping::types
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
MPI_Type_contiguous implementation for kamping::types::contiguous_type and kamping::types::byte_seria...
Type traits and dispatcher for mapping C++ types to MPI datatypes.
STL namespace.
Constructs a type serialized as a sequence of sizeof(T) bytes using MPI_BYTE.
Definition contiguous_type_fwd.hpp:49
The type trait that maps a C++ type T to an MPI_Datatype for the kamping-types module.
Definition mpi_type_traits.hpp:89
Internal type helpers for the kamping-types module.