-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrap.hpp
43 lines (36 loc) · 1.02 KB
/
wrap.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Utilities for working with wrapped types
*/
#ifndef _SEAL_C_WRAP_HPP
#define _SEAL_C_WRAP_HPP
namespace seal_c {
namespace wrap {
template <typename unwrapped_type>
struct Wrap;
template <typename wrapped_type>
struct Unwrap;
// use to define Wrap<> and Unwrap<> specializations
//
// template<> struct Wrap<Foo*> : public WrapPair<Foo*, FooOpaqueRef> {};
// template<> struct Unwrap<FooOpaqueRef> : public WrapPair<Foo*, FooOpaqueRef> {};
template <typename Unwrapped, typename Wrapped>
struct WrapPair
{
typedef Unwrapped unwrapped_type;
typedef Wrapped wrapped_type;
};
template <typename Unwrapped>
static inline
typename Wrap<Unwrapped>::wrapped_type wrap (Unwrapped u)
{
return reinterpret_cast<typename Wrap<Unwrapped>::wrapped_type> (u);
}
template <typename Wrapped>
static inline
typename Unwrap<Wrapped>::unwrapped_type unwrap (Wrapped w)
{
return reinterpret_cast<typename Unwrap<Wrapped>::unwrapped_type> (w);
}
} // namespace wrap
} // namespace seal_c
#endif