|
Boost : |
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2008-01-05 08:11:28
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk