liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Copyright 2006-2019 Joaquin M Lopez Munoz.
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or copy at
 * http://www.boost.org/LICENSE_1_0.txt)
 *
 * See http://www.boost.org/libs/flyweight for library home page.
 */
 
#ifndef BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP
#define BOOST_FLYWEIGHT_DETAIL_DEFAULT_VALUE_POLICY_HPP
 
#if defined(_MSC_VER)
#pragma once
#endif
 
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/detail/workaround.hpp>
#include <boost/flyweight/detail/perfect_fwd.hpp>
#include <boost/flyweight/detail/value_tag.hpp>
 
/* Default value policy: the key is the same as the value.
 */
 
namespace boost{
 
namespace flyweights{
 
namespace detail{
 
template<typename Value>
struct default_value_policy:value_marker
{
  typedef Value key_type;
  typedef Value value_type;
 
  struct rep_type
  {
  /* template ctors */
 
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)&&\
    !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)&&\
    BOOST_WORKAROUND(BOOST_GCC,<=40603)
/* GCC bug: the default ctor generated by the variadic template ctor below
 * fails to value-initialize x.
 */
 
    rep_type():x(){}
#endif
 
#define BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY(args) \
  :x(BOOST_FLYWEIGHT_FORWARD(args)){}
 
  BOOST_FLYWEIGHT_PERFECT_FWD(
    explicit rep_type,
    BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY)
 
#undef BOOST_FLYWEIGHT_PERFECT_FWD_CTR_BODY
 
    rep_type(const rep_type& r):x(r.x){}
 
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
    rep_type(rep_type&& r):x(std::move(r.x)){}
#endif
 
    operator const value_type&()const{return x;}
 
    value_type x;
  };
 
  static void construct_value(const rep_type&){}
  static void copy_value(const rep_type&){}
 
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  static void move_value(const rep_type&){}
#endif
};
 
} /* namespace flyweights::detail */
 
} /* namespace flyweights */
 
} /* namespace boost */
 
#endif