[compressed_pair] using compressed_pair to substitute a possibly empty member

Hi, I'm using compressed_pair to substitute a possibly empty member whose type is specified by a template argument and experience difficulties: template< typename T > class A { T x; public: // [ctor, ...] void foo() const { // if T is a reference type, non-const access to the // object referenced by x is possible, here } }; // but: template< typename T > class changed_A : boost::compressed_pair<T,boost::blank> { public: // [ctor, ...] void foo() const { // first() always returns a reference to const // even if T is a reference to non-const } }; So: Did I find a subtle design flaw or bug in compressed_pair or is it just the use case I'm throwing at it? In case of the latter we should probably introduce a compressed_member (or so) and have it implement const semantics consistent with members. Regards, Tobias
participants (1)
-
Tobias Schwinger