Bond
 
Loading...
Searching...
No Matches
double_pass.h
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#pragma once
5
6#include <bond/core/config.h>
7
8#include <bond/core/bond_fwd.h>
9
10#include <boost/utility/enable_if.hpp>
11
12namespace bond
13{
14 namespace detail
15 {
16 template <typename Transform, typename Enable = void> struct
17 need_double_pass
18 : std::false_type {};
19
20 template <typename Transform> struct
21 need_double_pass<
22 Transform,
23 typename boost::enable_if_c<!std::is_same<typename Transform::writer_type,
24 typename Transform::writer_type::Pass0>::value>::type
25 > : std::true_type {};
26
27 template <typename Protocols, typename Transform, typename T>
28 inline bool DoublePassApply(const Transform& transform, const T& value)
29 {
30 typedef typename Transform::writer_type Writer;
31 typedef Serializer<Writer, Protocols> Serializer;
32
33 typename Writer::Pass0::Buffer output;
34 typename Writer::Pass0 pass0(output, transform.Serializer::_output);
35
36 Apply<Protocols>(transform.Rebind(pass0), value);
37 return transform.Serializer::_output.WithPass0(pass0), Apply<Protocols>(transform, value);
38 }
39
40 } // namespace detail
41
42} // namespace bond
namespace bond
Definition: apply.h:17