forked from stlab/adobe_source_libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoly_regular.hpp
119 lines (84 loc) · 3.49 KB
/
poly_regular.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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
Copyright 2006-2007 Adobe Systems Incorporated
Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
or a copy at http://stlab.adobe.com/licenses.html)
Author(s): Mat Marcus
*/
/**************************************************************************************************/
#ifndef ADOBE_POLY_REGULAR_HPP
#define ADOBE_POLY_REGULAR_HPP
#include <adobe/config.hpp>
#include <boost/concept_check.hpp>
#include <adobe/empty.hpp>
#include <adobe/poly.hpp>
#include <adobe/regular_concept.hpp>
/**************************************************************************************************/
namespace adobe {
/*!
\ingroup poly_related
*/
/**************************************************************************************************/
/*!
\brief Virtual interface for RegularConcept. Used in poly<regular> implementation.
\sa regular, poly_regular_instance, poly_copyable_interface, RegularConcept
*/
struct poly_regular_interface : poly_copyable_interface {
virtual bool equals(const poly_regular_interface& new_value) const = 0;
};
/**************************************************************************************************/
/*!
\ingroup poly_related
\brief Implementation of a trivial poly interface in terms of types modeling regular .
Used in poly<regular> implementation.
\sa regular, poly_regular_interface, poly_copyable_interface, optimized_storage_type
*/
template <typename T>
struct poly_regular_instance : optimized_storage_type<T, poly_regular_interface>::type {
typedef typename optimized_storage_type<T, poly_regular_interface>::type base_t;
/*!
Check that T models appropriate concept for C++ 2003
*/
BOOST_CLASS_REQUIRE(T, adobe, RegularConcept);
/*!
Construct from concrete regular
*/
poly_regular_instance(const T& x) : base_t(x) {}
/*!
Move constructor
*/
poly_regular_instance(move_from<poly_regular_instance> x)
: base_t(move_from<base_t>(x.source)) {}
bool equals(const poly_regular_interface& x) const {
return this->type_info() == x.type_info() &&
this->get() == *static_cast<const T*>(x.cast());
}
};
/**************************************************************************************************/
/*!
\ingroup poly_related
\brief "Handle" class used in poly<regular> implementation.
\sa poly_regular_instance, poly_regular_interface, poly_copyable_interface, poly_base
*/
struct regular : poly_base<poly_regular_interface, poly_regular_instance> {
typedef poly_base<poly_regular_interface, poly_regular_instance> base_t;
/*!
Construct from concrete regular
*/
template <typename T>
explicit regular(const T& s) : base_t(s) {}
regular() : base_t(empty_t()) {}
/*!
Move constructor
*/
regular(move_from<regular> x) : base_t(move_from<base_t>(x.source)) {}
};
/**************************************************************************************************/
#if !defined(ADOBE_NO_DOCUMENTATION)
/**************************************************************************************************/
typedef poly<regular> poly_regular_t;
/**************************************************************************************************/
#endif
/**************************************************************************************************/
} // namespace adobe
/**************************************************************************************************/
#endif