autoppl  v0.8
A C++ template library for probabilistic programming
ptr_pack.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <cstddef>
4 
5 namespace ppl {
6 namespace util {
7 
8 template <class UCValPtrType
9  , class UCAdjPtrType
10  , class TPValPtrType
11  , class TPAdjPtrType
12  , class CValPtrType>
13 struct PtrPack
14 {
15  using uc_val_ptr_t = UCValPtrType;
16  using c_val_ptr_t = CValPtrType;
17  using tp_val_ptr_t = TPValPtrType;
18 
19  PtrPack(UCValPtrType _uc_val = nullptr,
20  UCAdjPtrType _uc_adj = nullptr,
21  TPValPtrType _tp_val = nullptr,
22  TPAdjPtrType _tp_adj = nullptr,
23  CValPtrType _c_val = nullptr,
24  size_t* _v_val = nullptr)
25  : uc_val{_uc_val}
26  , uc_adj{_uc_adj}
27  , tp_val{_tp_val}
28  , tp_adj{_tp_adj}
29  , c_val{_c_val}
30  , v_val{_v_val}
31  {}
32 
33  UCValPtrType uc_val;
34  UCAdjPtrType uc_adj;
35  TPValPtrType tp_val;
36  TPAdjPtrType tp_adj;
37  CValPtrType c_val;
38  size_t* v_val;
39 };
40 
41 template <class UCValPtrType = std::nullptr_t
42  , class UCAdjPtrType = std::nullptr_t
43  , class TPValPtrType = std::nullptr_t
44  , class TPAdjPtrType = std::nullptr_t
45  , class CValPtrType = std::nullptr_t>
46 constexpr inline auto
47 make_ptr_pack(UCValPtrType _uc_val = nullptr,
48  UCAdjPtrType _uc_adj = nullptr,
49  TPValPtrType _tp_val = nullptr,
50  TPAdjPtrType _tp_adj = nullptr,
51  CValPtrType _c_val = nullptr,
52  size_t* _v_val = nullptr)
53 {
54  return PtrPack<UCValPtrType,
55  UCAdjPtrType,
56  TPValPtrType,
57  TPAdjPtrType,
58  CValPtrType>(_uc_val, _uc_adj,
59  _tp_val, _tp_adj,
60  _c_val, _v_val);
61 }
62 
67 
68 // Set adjoint pointer type to void* to detect dereferencing at compile-time.
71  util::disc_param_t*, void*,
73 
74 } // namespace util
75 } // namespace ppl
ppl::util::PtrPack::c_val
CValPtrType c_val
Definition: ptr_pack.hpp:37
ppl::util::PtrPack::c_val_ptr_t
CValPtrType c_val_ptr_t
Definition: ptr_pack.hpp:16
ppl::util::PtrPack::tp_val_ptr_t
TPValPtrType tp_val_ptr_t
Definition: ptr_pack.hpp:17
ppl::util::PtrPack::uc_adj
UCAdjPtrType uc_adj
Definition: ptr_pack.hpp:34
dist_expr_traits.hpp
ppl::util::disc_param_t
int32_t disc_param_t
Definition: dist_expr_traits.hpp:15
ppl::util::PtrPack::uc_val
UCValPtrType uc_val
Definition: ptr_pack.hpp:33
ppl::util::make_ptr_pack
constexpr auto make_ptr_pack(UCValPtrType _uc_val=nullptr, UCAdjPtrType _uc_adj=nullptr, TPValPtrType _tp_val=nullptr, TPAdjPtrType _tp_adj=nullptr, CValPtrType _c_val=nullptr, size_t *_v_val=nullptr)
Definition: ptr_pack.hpp:47
ppl::util::PtrPack::tp_val
TPValPtrType tp_val
Definition: ptr_pack.hpp:35
ppl::util::cont_param_t
double cont_param_t
Definition: dist_expr_traits.hpp:14
ppl::util::PtrPack::PtrPack
PtrPack(UCValPtrType _uc_val=nullptr, UCAdjPtrType _uc_adj=nullptr, TPValPtrType _tp_val=nullptr, TPAdjPtrType _tp_adj=nullptr, CValPtrType _c_val=nullptr, size_t *_v_val=nullptr)
Definition: ptr_pack.hpp:19
ppl
Definition: bounded.hpp:11
ppl::util::PtrPack::tp_adj
TPAdjPtrType tp_adj
Definition: ptr_pack.hpp:36
ppl::util::PtrPack
Definition: ptr_pack.hpp:14
ppl::util::PtrPack::uc_val_ptr_t
UCValPtrType uc_val_ptr_t
Definition: ptr_pack.hpp:15
ppl::util::PtrPack::v_val
size_t * v_val
Definition: ptr_pack.hpp:38