Kevin Scaldeferri on 6 Aug 2003 23:21:46 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [ALACPP] problem with const



On Wednesday, August 6, 2003, at 02:39 PM, Jon Stewart wrote:

template<class FooType = Foo>
class Wrapper {
public:
	Wrapper(FooType& f) : m_Foo(f) {}

private:
	FooType& m_Foo;
};

Then, to get the correct const semantics:

const Wrapper<const Foo> w(myConstFooReference);

Ugly, but it works.

Critiques?


Well, the unfortunate thing is that it doesn't determine the const-ness of Wrapper automatically. You'd like

Wrapper<const Foo> w(myConstFooRef)

not to compile, I presume. I'm not sure how to achieve this with normal constructor semantics, though.


Kevin

_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp