|
Boost Users : |
Subject: [Boost-users] Error:" Non-const function called for const object" on Sun CC while using boost::multi_index::multi_index_container
From: Alexander Vinokur (Alexander.Vinokur_at_[hidden])
Date: 2008-10-07 11:13:03
Hi,
CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
Boost 1.34
Here are fragments of code that produces error "Non-const function
called for const object".
// --------------------
struct Foo
{
int m_int1;
int m_int2;
int get1 () const;
int get2 () const;;
~Foo();
};
int Foo::get1 () const;
{
return m_int1;
}
int Foo::get2 () const;
{
return m_int2;
}
Foo::~Foo()
{
}
// --------------------
typedef boost::multi_index::composite_key
<
Foo,
BOOST_MULTI_INDEX_CONST_MEM_FUN(
Foo,
int,
get1),
BOOST_MULTI_INDEX_CONST_MEM_FUN(
Foo,
int,
get2)
> FooKey;
// --------------------
typedef boost::multi_index::multi_index_container
<
Foo,
boost::multi_index::indexed_by
<
boost::multi_index::hashed_unique
<
FooKey
>
>
> FooContainer;
// ==================
// This function produces compilation error
void bar ()
{
FooContainer fooContainer;
}
Error message:
"/home/BOOST/boost_1_34_0/boost/detail/allocator_utilities.hpp", line
176: Error: Non-const function Foo::__SLIP.DELETER__H() called for const
object.
"/home/BOOST/boost_1_34_0/boost/multi_index/detail/index_base.hpp", line
105: Where: While instantiating
"boost::detail::allocator::destroy<Foo>(const Foo*)".
"/home/BOOST/boost_1_34_0/boost/multi_index/detail/index_base.hpp", line
105: Where: Instantiated from non-template code.
Important. If destructor ~Foo() is not virtual then there are no errors.
Alex Vinokur
This message and the information contained herein is proprietary and confidential and subject to the Amdocs policy statement,
you may review at http://www.amdocs.com/email_disclaimer.asp
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net