C++相談室 part13
■ このスレッドは過去ログ倉庫に格納されています
0663デフォルトの名無しさん
NGNGそれだけでいいのなら
property<T> の代わりに T でいいんじゃないか?
#include <boost/bind.hpp>
#include <boost/function.hpp>
template<typename T>
class property {
boost::function<T> getterFunc;
boost::function<void, const T&> setterFunc;
public:
template<typename Owner, typename G>
property( Owner& p, G g )
: getterFunc( boost::bind( g, p ) ) {}
template<typename Owner, typename G, typename S>
property( Owner& p, G g, S s )
: getterFunc( boost::bind( g, p ) )
, setterFunc( boost::bind( s, p, _1 ) ) {}
public:
operator T() const { return getterFunc(); }
property& operator=( const T& rhs ) {
setterFunc( rhs ); return *this;
}
};
■ このスレッドは過去ログ倉庫に格納されています