Hello,
 
I have a small problem. Some of my data holders have dereference operator which returns refernces to contained types. The problem I face here is that I have some noncopyable types and the dereference operator fails to compile.
 
I thought using a reference_wrapper class could do the trick, but then I can not call functions on the contained type without explict casting, regardless operator T&() const defined.
 
here is a small test app to simulate the behavior:
 

#include <boost/ref.hpp>

#include <boost/array.hpp>

#include <boost/utility.hpp>

 

using namespace std;

 

 

template<class T>

struct test

{

      test() : ptr(new T())

      {}

 

      ~test()

      {

            delete ptr;

      }

 

      boost::reference_wrapper<T> operator*()

      {

            return boost::ref(*ptr);

      }

 

      T* ptr;

};

 

template<class T, int N>

class array : public boost::array<T,N>

                  , private boost::noncopyable

{};

 

 

int main(int argc, char* argv[])

{

      test< array<int,10> > t;

 

      int size = (static_cast<array<int,10>&>(*t)).size();

}

 

Is there any way to call the last line like:

      int size = (*t).size();

 

operator ->() would work just fine, but I need to support both.

 

 

Thanks for help,

Ovanes Markarian