8#ifndef ADOBE_FUNCTION_HPP
9#define ADOBE_FUNCTION_HPP
28 const char*
what()
const throw() {
return message_m.c_str(); }
35 const char* result =
"unknown_exception";
39 }
catch (
const std::exception& error) {
41 result = error.what();
53namespace implementation {
62 operator bool()
const {
return self()->object_m; }
71 friend inline void swap(T& x, T& y) { x.swap(y); }
76 T* self() {
return static_cast<T*
>(
this); }
77 const T* self()
const {
return static_cast<const T*
>(
this); }
80template <
typename Concept,
typename Apply>
83 Concept* (*copy)(
const Concept*, string_t& message);
87template <
typename Concept,
typename V>
88struct concept_base_t {
89 explicit concept_base_t(
const V* x) : vtable_m(x) {}
91 Concept*
copy()
const {
93 Concept* result = vtable_m->copy(self(), message);
99 void destroy() { vtable_m->destroy(self()); }
101 Concept* self() {
return static_cast<Concept*
>(
this); }
102 const Concept* self()
const {
return static_cast<const Concept*
>(
this); }
107template <
typename Model,
typename Concept>
108struct model_base : Concept {
109 template <
typename T>
110 explicit model_base(T x) : Concept(x) {}
112 static Model* self(Concept* x) {
return static_cast<Model*
>(x); }
113 static const Model* self(
const Concept* x) {
return static_cast<const Model*
>(x); }
115 static void destroy(Concept* x) {
delete self(x); }
117 static Concept*
copy(
const Concept* x, string_t& message) {
121 result =
new Model(*self(x));
130template <
typename F,
typename T>
131typename F::concept_t* make_model(
const T& x) {
132 return new typename F::template model<T>(x);
135template <
typename F,
typename T>
136typename F::concept_t* create_model(
const T& x, std::true_type) {
137 return x ? make_model<F>(std::bind<typename F::result_type>(x)) : 0;
140template <
typename F,
typename T>
141typename F::concept_t* create_model(
const T& x, std::false_type) {
142 return make_model<F>(std::bind<typename F::result_type>(x));
145template <
typename F,
typename T>
146typename F::concept_t* create_model(
const T& x) {
147 return create_model<F>(x, std::is_pointer<T>());
154inline namespace version_1 {
185class function<R()> :
public implementation::function_base<function<R()>> {
193 template <
typename T>
205 template <
typename T>
219 throw std::bad_function_call();
220 return object_m->apply();
226 friend class implementation::function_base<
function<R()>>;
228 typedef implementation::vtable<concept_t, R (*)(concept_t*, string_t&)> vtable_type;
237 struct concept_t : implementation::concept_base_t<concept_t, vtable_type> {
238 typedef implementation::concept_base_t<concept_t, vtable_type>
base_type;
245 this->vtable_m->apply(
this, message);
252 R result = this->vtable_m->apply(
this, message);
259 template <
typename T>
260 struct model : implementation::model_base<model<T>, concept_t> {
266 return apply(x, message,
typename std::is_void<R>());
298 &model::destroy, &model::copy, &model::apply};
marshaled_exception(string_t message)
const char * what() const
function & operator=(T x)
function & operator=(null_ptr_t)
function(const function &x)
function & operator=(function x)
OutputIterator copy(const InputRange &range, OutputIterator result)
copy implementation
void swap(any_regular_t &x, any_regular_t &y)
bool operator!=(const function< F > &x, null_ptr_t)
bool operator==(const any_regular_t &x, const any_regular_t &y)
const char * current_exception_what()
void swap(adobe::extents_t::slice_t &x, adobe::extents_t::slice_t &y) BOOST_NOEXCEPT
implementation::concept_base_t< concept_t, vtable_type > base_type
void apply(std::true_type)
concept_t(const vtable_type *x)
static void apply(concept_t *x, string_t &message, std::true_type)
static const vtable_type vtable_s
static R apply(concept_t *x, string_t &message, std::false_type)
implementation::model_base< model< T >, concept_t > base_type
static R apply(concept_t *x, string_t &message)