blob: 493ba9101e80e7a259521f6d8997d4889a671cb6 (
plain) (
blame)
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
|
#ifndef SERIALIZE_PTR_INL_H_
#error "Direct inclusion of this file is not allowed, include serialize.h"
// For the sake of sane code completion.
#include "serialize.h"
#endif
#include "new.h"
////////////////////////////////////////////////////////////////////////////////
template <class T>
void TSerializer<NYT::TIntrusivePtr<T>>::Save(IOutputStream* output, const NYT::TIntrusivePtr<T>& ptr)
{
bool hasValue = ptr.operator bool();
::Save(output, hasValue);
if (hasValue) {
::Save(output, *ptr);
}
}
template <class T>
void TSerializer<NYT::TIntrusivePtr<T>>::Load(IInputStream* input, NYT::TIntrusivePtr<T>& ptr)
{
bool hasValue;
::Load(input, hasValue);
if (hasValue) {
auto tmp = NYT::New<T>();
::Load(input, *tmp);
ptr = std::move(tmp);
} else {
ptr.Reset();
}
}
////////////////////////////////////////////////////////////////////////////////
|