#pragma once #include namespace fc { template typename shared_impl::impl& shared_impl::operator* ()const { return *_impl; } template typename shared_impl::impl* shared_impl::operator-> ()const { return _impl.get(); } template template shared_impl::shared_impl( U&& u ):_impl(fc::forward(u)){} template shared_impl::shared_impl( const shared_impl& u ):_impl(u._impl){} template shared_impl::shared_impl( shared_impl&& u ):_impl(fc::move(u._impl)){} template shared_impl& shared_impl::operator=( shared_impl&& u ) { fc_swap(_impl,u._impl); return *this; } template shared_impl& shared_impl::operator=( const shared_impl& u ) { _impl = u._impl; return *this; } template bool shared_impl::operator !()const { return !_impl; } template shared_impl::~shared_impl(){} } #define FC_REFERENCE_TYPE_IMPL( TYPE ) \ template \ TYPE::TYPE( A1&& a1 ) \ :my( new typename fc::shared_impl::impl( fc::forward(a1) ) ){}\ template \ TYPE::TYPE( A1&& a1, A2&& a2 ) \ :my( new typename fc::shared_impl::impl( fc::forward(a1), fc::forward(a2) ) ){}\ template \ TYPE::TYPE( A1&& a1, A2&& a2, A3&& a3 ) \ :my( new fc::shared_impl::impl( fc::forward(a1), fc::forward(a2), fc::forward(a3) ) ){}\ TYPE::TYPE( shared_impl::impl* m ) \ :my(m){}\ TYPE::TYPE( TYPE* c )\ :my(fc::move(c->my)){ delete c; }\ TYPE::TYPE( TYPE&& c )\ :my(fc::move(c.my)){}\ TYPE::TYPE( const TYPE& c )\ :my(c.my){}\ TYPE::TYPE() \ :my( new fc::shared_impl::impl( ) ){}\ TYPE::~TYPE(){}\ bool TYPE::operator !()const { return !my; }\ TYPE& TYPE::operator = ( const TYPE& c ) {\ my = c.my;\ return *this;\ }\ TYPE& TYPE::operator = ( TYPE&& c ) {\ fc_swap( my._impl, c.my._impl );\ return *this;\ }\ TYPE& TYPE::operator = ( TYPE* c ) {\ fc_swap( my._impl, c->my._impl );\ delete c;\ return *this;\ } \ bool operator==( const TYPE& a, const TYPE& b ) {\ return a.my._impl.get() == b.my._impl.get(); \ } \ bool operator!=( const TYPE& a, const TYPE& b ) {\ return a.my._impl.get() != b.my._impl.get(); \ }