diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-04 13:29:42 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-04 13:29:42 +0200 |
commit | 9ac9bb98f307156c02fa19ea747cf5eb1d2dcadf (patch) | |
tree | 8237f586c0198b82c186e7e7700ff9aaf7405bd5 /odb/details | |
parent | 1d2e161846310145c8bf4343a041818c57ca611e (diff) |
Add support for value wrappers
Wrapper is a class that wraps another type. Examples of wrappers are
various smart pointers, holders, etc. A wrapper can be transparent or
it can handle the NULL semantics.
The new odb::nullable class template is a NULL wrapper that helps
to add the NULL semantics to a value type.
New test: common/wrapper.
Diffstat (limited to 'odb/details')
-rw-r--r-- | odb/details/wrapper-p.hxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/odb/details/wrapper-p.hxx b/odb/details/wrapper-p.hxx new file mode 100644 index 0000000..7736fc9 --- /dev/null +++ b/odb/details/wrapper-p.hxx @@ -0,0 +1,40 @@ +// file : odb/details/wrapper-p.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_WRAPPER_P_HXX +#define ODB_DETAILS_WRAPPER_P_HXX + +#include <odb/pre.hxx> + +#include <odb/wrapper-traits.hxx> + +#include <odb/details/meta/answer.hxx> + +namespace odb +{ + namespace details + { + // GCC doesn't like these to be inside wrapper_p. + // + template <typename T> + meta::no + wrapper_p_test (...); + + template <typename T> + meta::yes + wrapper_p_test (typename wrapper_traits<T>::wrapped_type*); + + template <typename T> + struct wrapper_p + { + static const bool r = + sizeof (wrapper_p_test<T> (0)) == sizeof (meta::yes); + }; + } +} + +#include <odb/post.hxx> + +#endif // ODB_DETAILS_WRAPPER_P_HXX |