32 #ifndef MADNESS_WORLD_ARCHIVE_H__INCLUDED
33 #define MADNESS_WORLD_ARCHIVE_H__INCLUDED
42 #include <type_traits>
56 #include <madness/config.h>
62 #define ARCHIVE_COOKIE "archive"
65 #define ARCHIVE_MAJOR_VERSION 0
67 #define ARCHIVE_MINOR_VERSION 1
72 #ifdef MAD_ARCHIVE_DEBUG_ENABLE
73 #define MAD_ARCHIVE_DEBUG(s) s
76 #define MAD_ARCHIVE_DEBUG(s)
82 template <
typename T>
class Tensor;
90 inline archive_array<T>
wrap(
const T*,
unsigned int);
92 inline archive_array<unsigned char>
wrap_opaque(
const T*,
unsigned int);
94 inline archive_array<unsigned char>
wrap_opaque(
const T&);
114 template <
typename T>
123 template <
typename T>
134 #define ARCHIVE_REGISTER_TYPE(T, cooky) \
136 struct archive_typeinfo< T > { \
137 static const unsigned char cookie = cooky; \
145 #define ARCHIVE_REGISTER_TYPE_AND_PTR(T, cooky) \
146 ARCHIVE_REGISTER_TYPE(T, cooky); \
147 ARCHIVE_REGISTER_TYPE(T*, cooky+64)
151 #define ATN ::madness::archive::archive_type_names
153 #define ATI ::madness::archive::archive_typeinfo
159 #define ARCHIVE_REGISTER_TYPE_NAME(T) \
160 if (strcmp( ATN[ATI< T >::cookie], "invalid") ) { \
161 std::cout << "archive_register_type_name: slot/cookie already in use! " << #T << " " << ATN[ATI< T >::cookie] << std::endl; \
162 MADNESS_EXCEPTION("archive_register_type_name: slot/cookie already in use!", 0); \
164 ATN[ATI< T >::cookie] = #T
170 #define ARCHIVE_REGISTER_TYPE_AND_PTR_NAMES(T) \
171 ARCHIVE_REGISTER_TYPE_NAME(T); \
172 ARCHIVE_REGISTER_TYPE_NAME(T*)
176 #ifndef DOXYGEN_SHOULD_SKIP_THIS
236 template <typename T, typename = std::enable_if_t<std::is_function<T>::value || is_function_pointer<T>::value>>
238 std::ptrdiff_t retval;
240 #if __cplusplus >= 201703L
243 (std::is_function<T>::value) {
244 static_assert(
sizeof(std::ptrdiff_t) ==
sizeof(
T*));
245 retval =
reinterpret_cast<std::ptrdiff_t
>(&fn) -
fn_ptr_origin();
248 #if __cplusplus >= 201703L
249 static_assert(
sizeof(std::ptrdiff_t) ==
sizeof(
T));
251 retval =
reinterpret_cast<std::ptrdiff_t
>(fn) -
fn_ptr_origin();
258 template <typename T, typename = std::enable_if_t<std::is_member_function_pointer<T>::value>>
261 #if MADNESS_CXX_ABI == MADNESS_CXX_ABI_GenericItanium || MADNESS_CXX_ABI == MADNESS_CXX_ABI_GenericARM
262 static_assert(
sizeof(
T) %
sizeof(ptrdiff_t) == 0);
263 using result_t = std::array<std::ptrdiff_t,
sizeof(
T) /
sizeof(ptrdiff_t)>;
264 #elif MADNESS_CXX_ABI == MADNESS_CXX_ABI_Microsoft
270 static_assert(
sizeof(
T) %
sizeof(ptrdiff_t) == 0);
271 using result_t = std::array<std::ptrdiff_t,
sizeof(
T) /
sizeof(ptrdiff_t)>;
275 std::memcpy(&result, &fn,
sizeof(result_t));
281 #if MADNESS_CXX_ABI == MADNESS_CXX_ABI_GenericItanium
283 if (result[0] == 0) {
284 result[1] = std::numeric_limits<std::ptrdiff_t>::min();
286 else if ((result[0] & 1) == 0) {
289 #elif MADNESS_CXX_ABI == MADNESS_CXX_ABI_GenericARM
291 const auto even_adj = (result[1] & 1) == 0;
293 if (result[0] == 0) {
294 result[0] = std::numeric_limits<std::ptrdiff_t>::min();
300 #elif MADNESS_CXX_ABI == MADNESS_CXX_ABI_Microsoft
303 #warning "Support for serializing member function pointers in Microsoft ABI is not complete"
313 template <
typename T,
typename = std::enable_if_t<is_function_po
inter_v<T>>>
315 static_assert(
sizeof(std::ptrdiff_t) ==
sizeof(
T));
324 template <
typename T, std::
size_t N,
typename = std::enable_if_t<std::is_member_function_po
inter<std::remove_reference_t<T>>::value>>
327 #if MADNESS_CXX_ABI == MADNESS_CXX_ABI_GenericItanium
328 if (rel_fn_ptr[0] == 0 && rel_fn_ptr[1] == std::numeric_limits<std::ptrdiff_t>::min()) {
331 else if ((rel_fn_ptr[0] & 1) == 0) {
334 #elif MADNESS_CXX_ABI == MADNESS_CXX_ABI_GenericARM
335 const auto even_adj = (rel_fn_ptr[1] & 1) == 0;
337 if (rel_fn_ptr[0] == std::numeric_limits<std::ptrdiff_t>::min()) {
344 #elif MADNESS_CXX_ABI == MADNESS_CXX_ABI_Microsoft
346 using result_t = std::remove_reference_t<T>;
348 std::memcpy(&result, &rel_fn_ptr,
sizeof(result_t));
398 template <
class Archive,
class T>
399 typename std::enable_if_t< is_output_archive<Archive>::value &&
401 is_function_pointer_v<T>,
void>
405 std::vector<std::ptrdiff_t> t_rel(n);
409 ar.store(t_rel.data(), n);
412 template <
class Archive,
class T>
413 typename std::enable_if_t< is_output_archive<Archive>::value &&
415 std::is_member_function_pointer<T>::value,
void>
419 static_assert(
sizeof(rel_memfn_ptr_t) %
sizeof(std::ptrdiff_t) == 0);
420 constexpr std::size_t memfn_ptr_width =
sizeof(rel_memfn_ptr_t) /
sizeof(std::ptrdiff_t);
421 std::vector<rel_memfn_ptr_t> t_rel(n);
425 ar.store(
reinterpret_cast<std::ptrdiff_t*
>(t_rel.data()), n * memfn_ptr_width);
428 template <
class Archive,
class T>
429 typename std::enable_if_t< is_output_archive<Archive>::value &&
430 !(is_function_pointer_v<T> || std::is_member_function_pointer<T>::value) &&
448 template <
class Archive,
class T>
449 typename std::enable_if_t< is_input_archive<Archive>::value &&
451 is_function_pointer_v<T>,
void>
455 std::vector<std::ptrdiff_t> t_rel(n);
456 ar.load(t_rel.data(),n);
458 return to_abs_fn_ptr<T>(fn_ptr_rel);
462 template <
class Archive,
class T>
463 typename std::enable_if_t< is_input_archive<Archive>::value &&
465 std::is_member_function_pointer<T>::value,
void>
469 static_assert(
sizeof(rel_memfn_ptr_t) %
sizeof(std::ptrdiff_t) == 0);
470 constexpr std::size_t memfn_ptr_width =
sizeof(rel_memfn_ptr_t) /
sizeof(std::ptrdiff_t);
471 std::vector<rel_memfn_ptr_t> t_rel(n);
472 ar.load(
reinterpret_cast<std::ptrdiff_t*
>(t_rel.data()), n * memfn_ptr_width);
473 std::transform(begin(t_rel), end(t_rel), (
T*)t, [](
auto& memfn_ptr_rel) {
474 return to_abs_memfn_ptr<T>(memfn_ptr_rel);
478 template <
class Archive,
class T>
480 !(is_function_pointer_v<T> || std::is_member_function_pointer<T>::value),
void>
495 template <
class Archive,
class T>
499 for (
unsigned int i=0; i<n; ++i)
508 template <
class Archive,
class T>
515 unsigned char cookie;
520 std::snprintf(msg,
bufsize,
"InputArchive type mismatch: expected cookie "
521 "%u (%s) but got %u (%s) instead",
524 std::cerr << msg << std::endl;
553 template <
class Archive,
class T,
typename Enabler>
559 template <
typename A = Archive,
typename U = T,
typename = std::enable_if_t<has_member_serialize_v<U,A>>>
561 constexpr
auto has_serialize = has_member_serialize_v<T,Archive>;
562 if constexpr (has_serialize)
565 constexpr
auto T_has_serialize_method = !has_serialize;
566 static_assert(T_has_serialize_method);
580 template <
class Archive,
class T>
584 MAD_ARCHIVE_DEBUG(std::cout <<
"default_serialize(ar,t) -> default_serialize(ar,&t,1)" << std::endl);
597 template <
class Archive,
class T>
601 MAD_ARCHIVE_DEBUG(std::cout <<
"serialize(ar,t) -> ArchiveSerializeImpl" << std::endl);
610 template <
class Archive,
class T,
typename Enabler>
613 template <
typename A = Archive,
typename U = T>
614 static inline std::enable_if_t<is_output_archive_v<A> &&
615 !std::is_function<U>::value &&
616 (has_member_serialize_v<U,A> ||
617 has_nonmember_serialize_v<U,A> ||
618 has_freestanding_serialize_v<U, A> ||
619 has_freestanding_default_serialize_v<U, A>),
623 if constexpr (has_member_serialize_v<U,A>) {
626 else if constexpr (has_nonmember_serialize_v<U,A>) {
629 else if constexpr (has_freestanding_serialize_v<U, A>) {
632 else if constexpr (has_freestanding_default_serialize_v<U, A>) {
643 template <
typename A = Archive,
typename U =
T,
644 typename = std::enable_if_t<is_output_archive_v<A> &&
645 std::is_function<U>::value>>
646 static inline void store(
const Archive& ar,
const U& t) {
649 std::add_pointer_t<U> fn_ptr = &t;
665 template <
class Archive,
class T,
typename Enabler>
671 template <
typename A = Archive,
673 typename = std::enable_if_t<is_input_archive_v<A> &&
674 (has_member_serialize_v<U,A> ||
675 has_nonmember_serialize_v<U,A> ||
676 has_freestanding_serialize_v<U, A> ||
677 has_freestanding_default_serialize_v<U, A>)>>
678 static inline void load(
const A& ar,
const U& t) {
680 if constexpr (has_member_serialize_v<U,A>) {
683 else if constexpr (has_nonmember_serialize_v<U,A>) {
686 else if constexpr (has_freestanding_serialize_v<U, A>) {
689 else if constexpr (has_freestanding_default_serialize_v<U, A>) {
700 template <
typename A = Archive,
typename U =
T,
701 typename = std::enable_if_t<is_input_archive_v<A> &&
702 std::is_function<U>::value>>
703 static inline void load(
const Archive& ar, U& t) {
706 std::add_pointer_t<U> fn_ptr;
725 template <
class Archive,
class T,
typename Enabler>
732 template <
typename A = Archive,
typename = std::enable_if_t<is_output_archive_v<A> && has_nonmember_store_v<T,Archive>>>
733 static inline const Archive&
wrap_store(
const Archive& ar,
const T& t) {
746 template <
typename A = Archive,
typename = std::enable_if_t<is_input_archive_v<A> && has_nonmember_load_v<T,Archive>>>
747 static inline const Archive&
wrap_load(
const Archive& ar,
const T& t) {
765 template <
class Archive,
class T>
767 std::enable_if_t<is_output_archive_v<Archive>,
const Archive&>
770 if constexpr (!is_serializable_v<Archive,T>) {
771 constexpr
bool T_is_serializable = is_serializable_v<Archive,T>;
772 static_assert(T_is_serializable,
"T is neither trivially serializable not provided serialization methods");
786 template <
class Archive,
class T>
788 std::enable_if_t<is_input_archive_v<Archive>,
const Archive&>
791 if constexpr (!is_serializable_v<Archive,T>) {
792 constexpr
bool T_is_serializable = is_serializable_v<Archive,T>;
793 static_assert(T_is_serializable,
"T is neither trivially serializable not provided serialization methods");
807 template <
class Archive,
class T>
809 std::enable_if_t<is_output_archive_v<Archive>,
const Archive&>
812 if constexpr (!is_serializable_v<Archive,T>) {
813 constexpr
bool T_is_serializable = is_serializable_v<Archive,T>;
814 static_assert(T_is_serializable,
"T is neither trivially serializable not provided serialization methods");
828 template <
class Archive,
class T>
830 std::enable_if_t<is_input_archive_v<Archive>,
const Archive&>
833 if constexpr (!is_serializable_v<Archive,T>) {
834 constexpr
bool T_is_serializable = is_serializable_v<Archive,T>;
835 static_assert(T_is_serializable,
"T is neither trivially serializable not provided serialization methods");
871 template <
class Archive>
945 template <
class Archive,
typename resT,
typename... paramT>
951 template <typename A = Archive, typename = std::enable_if_t<is_output_archive<A>::value>>
952 static inline void serialize(
const A& ar, resT(*(&fn))(paramT...)) {
956 template <
typename A = Archive>
957 static inline std::enable_if_t<!is_output_archive<A>::value,
void>
serialize(
const A& ar, resT(*(&fn))(paramT...)) {
958 std::ptrdiff_t rel_fn_ptr{};
960 fn =
to_abs_fn_ptr<std::remove_reference_t<decltype(fn)>>(rel_fn_ptr);
971 template <
class Archive,
typename resT,
typename objT,
typename... paramT>
973 std::enable_if_t<!is_default_serializable_v<Archive, resT(objT::*)(paramT...)>>> {
978 template <typename A = Archive, typename = std::enable_if_t<is_output_archive<A>::value>>
979 static inline void serialize(
const A& ar, resT(objT::*(&memfn))(paramT...)) {
983 template <
typename A = Archive>
984 static inline std::enable_if_t<!is_output_archive<A>::value,
void>
serialize(
const A& ar, resT(objT::*(&memfn))(paramT...)) {
986 rel_memfn_ptr_t rel_fn_ptr{};
988 memfn = to_abs_memfn_ptr<decltype(memfn)>(rel_fn_ptr);
998 template <
class Archive,
typename resT,
typename objT,
typename... paramT>
1000 std::enable_if_t<!is_default_serializable_v<Archive, resT(objT::*)(paramT...) const>>
1006 static inline void serialize(
const Archive& ar, resT(objT::*memfn)(paramT...)
const) {
1016 template <
class Archive,
class T>
1070 template <
class Archive,
class T, std::
size_t n>
1071 struct ArchiveImpl<Archive,
T[n],
std::enable_if_t<!std::is_same_v<T,char> && is_serializable_v<Archive, T>>> {
1077 static inline const Archive&
wrap_store(
const Archive& ar,
const T(&t)[n]) {
1079 ar <<
wrap(&t[0],n);
1088 static inline const Archive&
wrap_load(
const Archive& ar,
const T(&t)[n]) {
1090 ar >>
wrap(&t[0],n);
1100 template <
class Archive,
typename T>
1106 static inline void store(
const Archive& ar,
const std::complex<T>&
c) {
1108 ar &
c.real() &
c.imag();
1117 template <
class Archive,
typename T>
1123 static inline void load(
const Archive& ar, std::complex<T>&
c) {
1127 c = std::complex<T>(r,i);
1136 template <
class Archive,
typename T>
1143 static inline void store(
const Archive& ar,
const std::allocator<T>&
v) {
1153 template <
class Archive,
typename T>
1160 static void load(
const Archive& ar, std::allocator<T>&
v) {
1169 template <
class Archive,
typename T,
typename Alloc>
1170 struct ArchiveStoreImpl< Archive,
std::vector<T, Alloc>, std::enable_if_t<!is_future<T>::value && is_serializable_v<Archive, T>> > {
1176 static inline void store(
const Archive& ar,
const std::vector<T, Alloc>&
v) {
1177 MAD_ARCHIVE_DEBUG(std::cout <<
"serialize std::vector of plain data" << std::endl);
1178 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1179 ar &
v.get_allocator();
1182 ar &
wrap(
v.data(),
v.size());
1192 template <
class Archive,
typename T,
typename Alloc>
1193 struct ArchiveLoadImpl< Archive,
std::vector<T, Alloc>, std::enable_if_t<!is_future<T>::value && is_serializable_v<Archive, T>> > {
1200 static void load(
const Archive& ar, std::vector<T, Alloc>&
v) {
1201 MAD_ARCHIVE_DEBUG(std::cout <<
"deserialize std::vector of plain data" << std::endl);
1202 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1207 std::size_t n = 0ul;
1209 if (n !=
v.size()) {
1213 ar &
wrap((
T *)
v.data(),n);
1223 template <
class Archive,
typename Alloc>
1229 static inline void store(
const Archive& ar,
const std::vector<bool, Alloc>&
v) {
1231 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1232 ar &
v.get_allocator();
1234 std::size_t n =
v.size();
1235 bool*
b =
new bool[n];
1236 for (std::size_t i=0; i<n; ++i)
b[i] =
v[i];
1237 ar & n &
wrap(
b,
v.size());
1247 template <
class Archive,
typename Alloc>
1254 static void load(
const Archive& ar, std::vector<bool, Alloc>&
v) {
1256 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1261 std::size_t n = 0ul;
1263 if (n !=
v.size()) {
1267 bool*
b =
new bool[n];
1269 for (std::size_t i=0; i<n; ++i)
v[i] =
b[i];
1279 template <
class Archive,
typename T, std::
size_t N>
1286 static inline void store(
const Archive& ar,
const std::array<T, N>&
v) {
1287 MAD_ARCHIVE_DEBUG(std::cout <<
"serialize std::array<T," <<
N <<
">, with T plain data" << std::endl);
1289 ar &
wrap(
v.data(),
v.size());
1299 template <
class Archive,
typename T, std::
size_t N>
1306 static void load(
const Archive& ar, std::array<T, N>&
v) {
1307 MAD_ARCHIVE_DEBUG(std::cout <<
"deserialize std::array<T," <<
N <<
">, with T plain data" << std::endl);
1308 std::size_t n = 0ul;
1311 ar &
wrap((
T *)
v.data(),n);
1319 template <
class Archive>
1325 static void store(
const Archive& ar,
const std::string&
v) {
1328 ar &
wrap((
const char*)
v.data(),
v.size());
1336 template <
class Archive>
1343 static void load(
const Archive& ar, std::string&
v) {
1345 std::size_t n = 0ul;
1347 if (n !=
v.size()) {
1351 ar &
wrap((
char*)
v.data(),n);
1361 template <
class Archive,
typename T,
typename Q>
1362 struct ArchiveSerializeImpl< Archive,
std::pair<T, Q>, std::enable_if_t<is_serializable_v<Archive, T> && is_serializable_v<Archive, Q>> > {
1367 static inline void serialize(
const Archive& ar, std::pair<T,Q>& t) {
1369 ar & t.first & t.second;
1377 template <
class Archive,
typename T>
1383 static inline void serialize(
const Archive& ar, std::optional<T>& t) {
1385 if constexpr (is_output_archive_v<Archive>) {
1395 t = std::move(value);
1403 template <
size_t idx,
class Archive,
typename... Types>
1404 struct tuple_serialize_helper;
1406 template <
class Archive,
typename... Types>
1407 struct tuple_serialize_helper<0,Archive,Types...> {
1408 static void exec(
const Archive& ar, std::tuple<Types...>& t) {
1409 ar & std::get<0>(t);
1412 template <
size_t idx,
class Archive,
typename... Types>
1413 struct tuple_serialize_helper {
1414 static void exec(
const Archive& ar, std::tuple<Types...>& t) {
1415 ar & std::get<idx>(t);
1416 tuple_serialize_helper<idx-1,Archive,Types...>::exec(ar,t);
1426 template <
class Archive,
typename... Types>
1432 static inline void serialize(
const Archive& ar, std::tuple<Types...>& t) {
1434 constexpr
auto size = std::tuple_size<std::tuple<Types...>>::value;
1435 tuple_serialize_helper<size-1,Archive,Types...>::exec(ar, t);
1446 template <
class Archive,
typename T,
typename Q,
typename Compare,
typename Alloc>
1447 struct ArchiveStoreImpl< Archive,
std::map<T,Q,Compare,Alloc>, std::enable_if_t<is_serializable_v<Archive, T> && is_serializable_v<Archive, Q>> > {
1452 static void store(
const Archive& ar,
const std::map<T,Q,Compare,Alloc>& t) {
1454 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1455 ar & t.get_allocator();
1458 for (
auto p = t.begin();
1459 p != t.end(); ++
p) {
1465 std::pair<T,Q> pp = *
p;
1479 template <
class Archive,
typename T,
typename Q,
typename Compare,
typename Alloc>
1480 struct ArchiveLoadImpl< Archive,
std::map<T,Q,Compare,Alloc>, std::enable_if_t<is_serializable_v<Archive, T> && is_serializable_v<Archive, Q>> > {
1486 static void load(
const Archive& ar, std::map<T,Q,Compare,Alloc>& t) {
1488 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1491 t = std::map<T,Q,Compare,Alloc>(
allocator);
1500 t.emplace(std::move(
p.first), std::move(
p.second));
1512 template <
class Archive,
typename T,
typename Compare,
typename Alloc>
1513 struct ArchiveStoreImpl< Archive,
std::set<T, Compare, Alloc>, std::enable_if_t<!is_future<T>::value && is_serializable_v<Archive, T>> > {
1519 static inline void store(
const Archive& ar,
const std::set<T, Compare, Alloc>& s) {
1521 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1522 ar & s.get_allocator();
1525 for (
const auto &i : s)
1537 template <
class Archive,
typename T,
typename Compare,
typename Alloc>
1538 struct ArchiveLoadImpl< Archive,
std::set<T, Compare, Alloc>, std::enable_if_t<!is_future<T>::value && is_serializable_v<Archive, T>> > {
1543 static void load(
const Archive& ar, std::set<T, Compare, Alloc>& s) {
1545 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1548 s = std::set<T, Compare, Alloc>(
allocator);
1553 auto hint = s.begin();
1554 for (std::size_t i = 0; i < size; ++i)
1556 typename std::set<T, Compare, Alloc>::key_type key=0;
1558 hint = s.emplace_hint(hint, std::move(key));
1570 template <
class Archive,
typename T,
typename Alloc>
1571 struct ArchiveStoreImpl< Archive,
std::list<T,Alloc>, std::enable_if_t<!is_future<T>::value && is_serializable_v<Archive, T>> > {
1577 static inline void store(
const Archive& ar,
const std::list<T, Alloc>& s) {
1579 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1580 ar & s.get_allocator();
1583 for (
const auto &i : s)
1594 template <
class Archive,
typename T,
typename Alloc>
1595 struct ArchiveLoadImpl< Archive,
std::list<T, Alloc>, std::enable_if_t<!is_future<T>::value && is_serializable_v<Archive, T>> > {
1600 static void load(
const Archive& ar, std::list<T, Alloc>& s) {
1602 if constexpr (!std::allocator_traits<Alloc>::is_always_equal::value) {
1610 for (std::size_t i = 0; i < size; ++i)
1614 s.emplace_back(std::move(elem));
#define MAD_ARCHIVE_DEBUG(s)
Macro for helping debug archive tools.
Definition: archive.h:76
Definition: test_ar.cc:118
Base class for all archive classes.
Definition: archive.h:358
std::false_type is_loading
Type used by Boost.Serialization to determine if this object is an input archive.
Definition: archive.h:363
BaseArchive()
Definition: archive.h:367
std::false_type is_saving
Type used by Boost.Serialization to determine if this object is an output archive.
Definition: archive.h:364
static constexpr bool is_parallel_archive
Flag to determine if this object is a parallel archive.
Definition: archive.h:365
Base class for output archive classes.
Definition: archive.h:382
Wrapper for dynamic arrays and pointers.
Definition: archive.h:890
archive_array()
Constructor specifying no array and of 0 length.
Definition: archive.h:902
unsigned int n
The number of objects in the array.
Definition: archive.h:893
const T * ptr
The pointer.
Definition: archive.h:892
archive_array(const T *ptr, unsigned int n)
Constructor specifying a memory location and size.
Definition: archive.h:899
Wrapper for an opaque pointer for serialization purposes.
Definition: archive.h:850
archive_ptr(T *t=nullptr)
Constructor specifying nullptr by default.
Definition: archive.h:857
T * ptr
The pointer.
Definition: archive.h:852
void serialize(const Archive &ar)
Serialize the pointer.
Definition: archive.h:872
T & operator*()
Dereference the pointer.
Definition: archive.h:863
const std::size_t bufsize
Definition: derivatives.cc:16
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition: derivatives.cc:72
std::vector< Fcwf > transform(World &world, std::vector< Fcwf > &a, Tensor< std::complex< double >> U)
Definition: fcwf.cc:477
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
archive_array< unsigned char > wrap_opaque(const T *, unsigned int)
Factory function to wrap a pointer to contiguous data as an opaque (uchar) archive_array.
Definition: archive.h:925
const char * archive_type_names[256]
The list of type names for use in archives.
Definition: archive_type_names.cc:46
const char * get_type_name()
Returns the name of the type, or unknown if not registered.
Definition: archive.h:124
std::enable_if_t< is_output_archive_v< Archive >, const Archive & > operator&(const Archive &ar, const T &t)
Redirect & to ArchiveImpl::wrap_store for output archives.
Definition: archive.h:810
std::ptrdiff_t fn_ptr_origin()
Definition: archive.cc:52
std::enable_if_t< is_input_archive_v< Archive >, const Archive & > operator>>(const Archive &ar, const T &t)
Redirect >> to ArchiveImpl::wrap_load for input archives.
Definition: archive.h:789
std::ptrdiff_t to_rel_fn_ptr(const T &fn)
converts function or (free or static member) function pointer to the relative function pointer
Definition: archive.h:237
std::enable_if_t< is_output_archive_v< Archive >, const Archive & > operator<<(const Archive &ar, const T &t)
Redirect << to ArchiveImpl::wrap_store for output archives.
Definition: archive.h:768
T to_abs_fn_ptr(std::ptrdiff_t rel_fn_ptr)
converts relative free or static member function pointer to the absolute function pointer
Definition: archive.h:314
archive_ptr< T > wrap_ptr(T *p)
Wrapper for pointers.
Definition: archive.h:882
archive_array< T > wrap(const T *, unsigned int)
Factory function to wrap a dynamically allocated pointer as a typed archive_array.
Definition: archive.h:913
auto to_rel_memfn_ptr(const T &fn)
converts nonstatic member function pointer to the relative equivalent
Definition: archive.h:259
auto to_abs_memfn_ptr(std::array< std::ptrdiff_t, N > rel_fn_ptr)
converts relative (nonstatic) member function pointer to the absolute function pointer
Definition: archive.h:325
std::enable_if_t< ! is_default_serializable< Archive, T >::value &&is_archive< Archive >::value, void > serialize(const Archive &ar, const T *t, unsigned int n)
Serialize (or deserialize) an array of non-fundamental stuff.
Definition: archive.h:497
std::enable_if_t< is_output_archive< Archive >::value &&is_default_serializable< Archive, T >::value &&is_function_pointer_v< T >, void > default_serialize(const Archive &ar, const T *t, unsigned int n)
Serialize an array of fundamental stuff.
Definition: archive.h:402
void archive_initialize_type_names()
Initializes the type names for the archives.
Definition: archive_type_names.cc:53
static const double v
Definition: hatom_sf_dirac.cc:20
Defines madness::MadnessException for exception handling.
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition: madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition: madness_exception.h:134
ARCHIVE_REGISTER_TYPE_AND_PTR(A, 128)
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
constexpr bool has_freestanding_serialize_with_size_v
Definition: type_traits.h:416
constexpr bool has_freestanding_serialize_v
Definition: type_traits.h:408
constexpr bool is_default_serializable_v
Definition: type_traits.h:458
constexpr bool has_freestanding_default_serialize_v
Definition: type_traits.h:432
constexpr bool has_freestanding_default_serialize_with_size_v
Definition: type_traits.h:440
static const double b
Definition: nonlinschro.cc:119
static const double c
Definition: relops.cc:10
Definition: hatom_sf_dirac.cc:91
static const Archive & wrap_store(const Archive &ar, const T(&t)[n])
Store the array, wrapped by the preamble/postamble.
Definition: archive.h:1077
static const Archive & wrap_load(const Archive &ar, const T(&t)[n])
Load the array, using the preamble and postamble to perform runtime type-checking.
Definition: archive.h:1088
static const Archive & wrap_store(const Archive &ar, const archive_array< T > &t)
Store the archive_array, wrapped by the preamble/postamble.
Definition: archive.h:1023
static const Archive & wrap_load(const Archive &ar, const archive_array< T > &t)
Load the archive_array, using the preamble and postamble to perform runtime type-checking.
Definition: archive.h:1044
Default implementations of wrap_store and wrap_load.
Definition: archive.h:726
static const Archive & wrap_store(const Archive &ar, const T &t)
Store an object sandwiched between its preamble and postamble.
Definition: archive.h:733
static const Archive & wrap_load(const Archive &ar, const T &t)
Load an object sandwiched between its preamble and postamble.
Definition: archive.h:747
static void load(const Archive &ar, std::allocator< T > &v)
Loading a std::allocator is a no-op.
Definition: archive.h:1160
static void load(const Archive &ar, std::array< T, N > &v)
Load a std::array.
Definition: archive.h:1306
static void load(const Archive &ar, std::complex< T > &c)
Load a complex number.
Definition: archive.h:1123
static void load(const Archive &ar, std::list< T, Alloc > &s)
Definition: archive.h:1600
static void load(const Archive &ar, std::map< T, Q, Compare, Alloc > &t)
Load a map.
Definition: archive.h:1486
static void load(const Archive &ar, std::set< T, Compare, Alloc > &s)
Definition: archive.h:1543
static void load(const Archive &ar, std::string &v)
Load a string.
Definition: archive.h:1343
static void load(const Archive &ar, std::vector< T, Alloc > &v)
Load a std::vector.
Definition: archive.h:1200
static void load(const Archive &ar, std::vector< bool, Alloc > &v)
Load a vector<bool>.
Definition: archive.h:1254
Default load of an object via serialize(ar, t).
Definition: archive.h:666
static void load(const A &ar, const U &t)
Load an object.
Definition: archive.h:678
static void load(const Archive &ar, U &t)
Load function reference stored as function pointer.
Definition: archive.h:703
Default implementation of the pre/postamble for type checking.
Definition: archive.h:509
static void preamble_load(const Archive &ar)
Deserialize a cookie and check the type.
Definition: archive.h:513
static void postamble_store(const Archive &)
By default there is no postamble.
Definition: archive.h:545
static void postamble_load(const Archive &)
By default there is no postamble.
Definition: archive.h:542
static void preamble_store(const Archive &ar)
Serialize a cookie for type checking.
Definition: archive.h:535
static void serialize(const A &ar, resT(*(&fn))(paramT...))
Serialize the function pointer.
Definition: archive.h:952
static std::enable_if_t<!is_output_archive< A >::value, void > serialize(const A &ar, resT(*(&fn))(paramT...))
Definition: archive.h:957
static void serialize(const Archive &ar, resT(objT::*memfn)(paramT...) const)
Serialize the const member function pointer.
Definition: archive.h:1006
static void serialize(const A &ar, resT(objT::*(&memfn))(paramT...))
Serialize the member function pointer.
Definition: archive.h:979
static std::enable_if_t<!is_output_archive< A >::value, void > serialize(const A &ar, resT(objT::*(&memfn))(paramT...))
Definition: archive.h:984
static void serialize(const Archive &ar, std::optional< T > &t)
Serialize the std::optional.
Definition: archive.h:1383
static void serialize(const Archive &ar, std::pair< T, Q > &t)
Serialize the pair.
Definition: archive.h:1367
static void serialize(const Archive &ar, std::tuple< Types... > &t)
Serialize the std::tuple.
Definition: archive.h:1432
Default symmetric serialization of a non-fundamental type that has serialize method.
Definition: archive.h:554
static void serialize(const Archive &ar, T &t)
Serializes the type.
Definition: archive.h:560
static void store(const Archive &ar, const std::allocator< T > &v)
Storing a std::allocator is a no-op.
Definition: archive.h:1143
static void store(const Archive &ar, const std::array< T, N > &v)
Store a std::array.
Definition: archive.h:1286
static void store(const Archive &ar, const std::complex< T > &c)
Store a complex number.
Definition: archive.h:1106
static void store(const Archive &ar, const std::list< T, Alloc > &s)
Store a std::list.
Definition: archive.h:1577
static void store(const Archive &ar, const std::map< T, Q, Compare, Alloc > &t)
Store a map.
Definition: archive.h:1452
static void store(const Archive &ar, const std::set< T, Compare, Alloc > &s)
Store a std::set.
Definition: archive.h:1519
static void store(const Archive &ar, const std::string &v)
Store a string.
Definition: archive.h:1325
static void store(const Archive &ar, const std::vector< T, Alloc > &v)
Store a std::vector of plain data.
Definition: archive.h:1176
static void store(const Archive &ar, const std::vector< bool, Alloc > &v)
Store a vector<bool>.
Definition: archive.h:1229
Default store of an object via serialize(ar, t).
Definition: archive.h:611
static void store(const Archive &ar, const U &t)
Store function reference as a function pointer.
Definition: archive.h:646
static std::enable_if_t< is_output_archive_v< A > &&!std::is_function< U >::value &&(has_member_serialize_v< U, A >||has_nonmember_serialize_v< U, A >||has_freestanding_serialize_v< U, A >||has_freestanding_default_serialize_v< U, A >), void > store(const A &ar, const U &t)
Definition: archive.h:621
Used to enable type checking inside archives.
Definition: archive.h:115
static const unsigned char cookie
Numeric ID for the type; 255 indicates unknown type.
Definition: archive.h:116
Checks if T is an archive type.
Definition: type_traits.h:498
is std::true_type if T can be serialized to Archive without specialized serialize() method
Definition: type_traits.h:453
Checks if T is an output archive type.
Definition: type_traits.h:531
F allocator()
Definition: testcomplexfunctionsolver.cc:52
#define N
Definition: testconv.cc:37