|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65776 - in sandbox/opaque/boost/opaque: . meta_mixin
From: vicente.botet_at_[hidden]
Date: 2010-10-05 17:24:55
Author: viboes
Date: 2010-10-05 17:24:49 EDT (Tue, 05 Oct 2010)
New Revision: 65776
URL: http://svn.boost.org/trac/boost/changeset/65776
Log:
Opaque:
* change push_back by push_front
* added more meta-mixins
Text files modified:
sandbox/opaque/boost/opaque/meta_mixin/operators.hpp | 115 +++++++++++++++++++++++++++++++--------
sandbox/opaque/boost/opaque/private_opaque_class.hpp | 10 +-
sandbox/opaque/boost/opaque/public_opaque_class.hpp | 12 ++-
3 files changed, 103 insertions(+), 34 deletions(-)
Modified: sandbox/opaque/boost/opaque/meta_mixin/operators.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/meta_mixin/operators.hpp (original)
+++ sandbox/opaque/boost/opaque/meta_mixin/operators.hpp 2010-10-05 17:24:49 EDT (Tue, 05 Oct 2010)
@@ -102,6 +102,18 @@
};
};
+#define BOOST_OPAQUE_HIDING_LESS_THAN(Final, Bool) \
+ private :\
+ Bool operator<(const Final& rhs) const;
+
+ template <typename Bool=bool>
+ struct hiding_less_than {
+ template <typename Final, typename Base>
+ struct type: Base {
+ BOOST_OPAQUE_HIDING_LESS_THAN(Final,Bool)
+ };
+ };
+
//////////////////////////////////////////////////////////////////////////////
#define BOOST_OPAQUE_USING_LESS_THAN_EQUAL(Final,Bool) \
@@ -437,39 +449,82 @@
//////////////////////////////////////////////////////////////////////////////
-//~ template <typename Final, typename Base>
-//~ struct using_address_of : Base {
-//~ Final* operator&() {
-//~ return this;
-//~ }
-//~ };
+template <typename Final, typename Address, typename Base>
+struct using_address_of : Base {
+ Address operator&() {
+ return Address(&(Final::underlying(this)));
+ }
+};
//////////////////////////////////////////////////////////////////////////////
-//~ template <typename Final, typename Derreference=typename reference<Final::underlying_type>::type, typename Base>
-//~ struct using_derreference : Base {
-//~ Derreference operator*() {
-//~ return *(x.underlying());
-//~ }
-//~ };
+template <typename Final, typename Reference, typename Base>
+struct using_derreference : Base {
+ Reference operator*() {
+ return Reference(*(Final::underlying(this)));
+ }
+};
//////////////////////////////////////////////////////////////////////////////
-//~ template <typename Final, typename Pointer=typename pointer<Final::underlying_type>::type, typename Base>
-//~ struct using_member_access : Base {
-//~ Pointer operator->() {
-//~ return x.underlying().operator->();
-//~ }
-//~ };
+template <typename Final, typename Pointer, typename Base>
+struct using_member_access : Base {
+ Pointer operator->() {
+ return Final::underlying(this).operator->();
+ }
+};
//////////////////////////////////////////////////////////////////////////////
-//~ template <typename Final, class I, class R, typename Base>
-//~ struct using_subscript : Base {
-//~ R operator[](I n) {
-//~ return x.underlying()[i];
-//~ }
-//~ };
+template <typename Final, class I, class R, typename Base>
+struct using_subscript : Base {
+ R operator[](I n) {
+ return Final::underlying(this)[n];
+ }
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+template <typename Final, class RHS, class R, typename Base>
+struct using_comma : Base {
+ R operator,(RHS rhs) {
+ return (Final::underlying(this),rhs);
+ }
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+template <typename Final, class Sig, typename Base>
+struct using_function_call;
+
+template <typename Final, class R, typename Base>
+struct using_function_call<Final, R(), Base> : Base {
+ R operator()() {
+ return Final::underlying(this)();
+ }
+};
+
+template <typename Final, class R, class P1, typename Base>
+struct using_function_call<Final, R(P1), Base> : Base {
+ R operator()(P1 p1) {
+ return Final::underlying(this)(p1);
+ }
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+// As the NT is not related to the UT by derivation, we can not overload the
+// operator ->* with a pointer to a member of the UT.
+// The user will need to define a specific member function
+
+//template <typename Final, class PTM, class R, typename Base>
+//struct using_pointer_to_member : Base {
+// R operator->*(PTM m) {
+// return Final::underlying(this)->*m;
+// }
+//};
+
+
// Increment and decrement
//////////////////////////////////////////////////////////////////////////////
@@ -540,6 +595,8 @@
#if 0
// I don't know why this doesn't works :(
+// It works for gcc-3.4
+// It doesn't work for gcc-4.3
//////////////////////////////////////////////////////////////////////////////
@@ -577,6 +634,16 @@
};
//////////////////////////////////////////////////////////////////////////////
+ struct hiding_plus {
+ template <typename Final, typename Base>
+ struct type: Base {
+ private :
+ //friend Final operator+(const Final& lhs, const Final& rhs);
+ Final operator+(const Final& rhs) const;
+ };
+ };
+
+//////////////////////////////////////////////////////////////////////////////
struct using_minus {
template <typename Final, typename Base>
Modified: sandbox/opaque/boost/opaque/private_opaque_class.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/private_opaque_class.hpp (original)
+++ sandbox/opaque/boost/opaque/private_opaque_class.hpp 2010-10-05 17:24:49 EDT (Tue, 05 Oct 2010)
@@ -19,7 +19,7 @@
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/mpl/and.hpp>
-#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/push_front.hpp>
namespace boost {
class base_private_opaque_type {};
@@ -42,8 +42,8 @@
>
#else
new_class< Final, T,
- typename mpl::push_back<
- typename mpl::push_back<
+ typename mpl::push_front<
+ typename mpl::push_front<
MetaMixinSeq,
transitive_explicit_substituable<base_private_opaque_type, T>
>::type,
@@ -64,8 +64,8 @@
>
#else
new_class< Final, T,
- typename mpl::push_back<
- typename mpl::push_back<
+ typename mpl::push_front<
+ typename mpl::push_front<
MetaMixinSeq,
transitive_explicit_substituable<base_private_opaque_type, T>
>::type,
Modified: sandbox/opaque/boost/opaque/public_opaque_class.hpp
==============================================================================
--- sandbox/opaque/boost/opaque/public_opaque_class.hpp (original)
+++ sandbox/opaque/boost/opaque/public_opaque_class.hpp 2010-10-05 17:24:49 EDT (Tue, 05 Oct 2010)
@@ -21,7 +21,7 @@
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/vector.hpp>
-#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/push_front.hpp>
namespace boost {
@@ -80,11 +80,13 @@
>
#else
new_class< Final, T,
- typename mpl::push_back<
- typename mpl::push_back<
+ typename mpl::push_front<
+ typename mpl::push_front<
MetaMixinSeq,
transitive_substituable<base_public_opaque_type, T>
+ //opaque::inherited_from_underlying<T>
>::type,
+ // transitive_substituable<base_public_opaque_type, T>
opaque::inherited_from_underlying<T>
>::type, Base
>
@@ -107,8 +109,8 @@
>
#else
new_class< Final, T,
- typename mpl::push_back<
- typename mpl::push_back<
+ typename mpl::push_front<
+ typename mpl::push_front<
MetaMixinSeq,
transitive_substituable<base_public_opaque_type, T>
>::type,
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk