Subject: Re: [Boost-bugs] [Boost C++ Libraries] #730: The ptr_map iterator cannot be dereference to value type
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-08-21 21:08:55
#730: The ptr_map iterator cannot be dereference to value type
-----------------------+----------------------------------------------------
Reporter: zxing | Owner: nesotto
Type: Bugs | Status: new
Milestone: | Component: ptr_container
Version: None | Severity: Problem
Resolution: Rejected | Keywords:
-----------------------+----------------------------------------------------
Changes (by marshall):
* status: assigned => new
* component: None => ptr_container
* severity: => Problem
Old description:
> {{{
> The following code was built and worded well under
> VS.NET 2003 and boost v1.33. But under boost v1.34, it
> cannot built
>
> // testshareptr.cpp : Defines the entry point for the
> console application.
> //
>
> #include "stdafx.h"
> #include "C:\Dev\Head\Third Party Libraries\Public
> Headers\boost\ptr_container\ptr_map.hpp"
> #include "C:\Dev\Head\Third Party Libraries\Public
> Headers\boost\ptr_container\ptr_vector.hpp"
> #include "C:\Dev\Head\Third Party Libraries\Public
> Headers\boost\signal.hpp"
> #include "C:\Dev\Head\Third Party Libraries\Public
> Headers\boost\signals\slot.hpp"
> #include "C:\Dev\Head\Third Party Libraries\Public
> Headers\boost\signals\trackable.hpp"
> #include "C:\Dev\Head\Third Party Libraries\Public
> Headers\boost\signals\connection.hpp"
> #include "C:\Dev\Head\Third Party Libraries\Public
> Headers\boost\visit_each.hpp"
> #include "C:\Dev\Head\Third Party Libraries\Public
> Headers\boost\last_value.hpp"
> #include "C:\Dev\Head\Third Party Libraries\Public
> Headers\boost\lambda\algorithm.hpp"
> #include <algorithm>
> #include <functional>
>
> class TValue
> {
> private:
> int m_n;
>
> public:
>
> TValue(int n = 0)
> {
> m_n = n;
> printf("I am brith at %i\n", m_n);
> }
>
> ~TValue()
> {
> printf("I am %i and dying\n", m_n);
> }
>
> void WhoIs()
> {
> printf("I am %i\n", m_n);
> }
>
> int Get(void) const {return m_n;}
> int Get2(void) {return m_n;}
> };
>
> typedef boost::ptr_map<int, TValue>CMyMap;
>
> bool Larger(const TValue& p1, const TValue& p2)
> {
> bool bRet = false;
>
> bRet = (p2.Get() <= p1.Get() && (p2.Get()%2==0));
>
> return bRet;
> }
>
> void TestCase1()
> {
> printf("\n\n======================TestCase
> 1:======================\n");
> CMyMap mymap;
> for(int i = 0; i < 10; ++i)
> {
> mymap.insert(i, new TValue(i));
> }
>
> std::stable_sort(mymap.begin(), mymap.end(), Larger);
> }
>
>
> int _tmain(int argc, _TCHAR* argv[])
> {
> TestCase1();
> return 0;
> }
> }}}
New description:
{{{
The following code was built and worded well under
VS.NET 2003 and boost v1.33. But under boost v1.34, it
cannot built
// testshareptr.cpp : Defines the entry point for the
console application.
//
#include "stdafx.h"
#include "C:\Dev\Head\Third Party Libraries\Public
Headers\boost\ptr_container\ptr_map.hpp"
#include "C:\Dev\Head\Third Party Libraries\Public
Headers\boost\ptr_container\ptr_vector.hpp"
#include "C:\Dev\Head\Third Party Libraries\Public
Headers\boost\signal.hpp"
#include "C:\Dev\Head\Third Party Libraries\Public
Headers\boost\signals\slot.hpp"
#include "C:\Dev\Head\Third Party Libraries\Public
Headers\boost\signals\trackable.hpp"
#include "C:\Dev\Head\Third Party Libraries\Public
Headers\boost\signals\connection.hpp"
#include "C:\Dev\Head\Third Party Libraries\Public
Headers\boost\visit_each.hpp"
#include "C:\Dev\Head\Third Party Libraries\Public
Headers\boost\last_value.hpp"
#include "C:\Dev\Head\Third Party Libraries\Public
Headers\boost\lambda\algorithm.hpp"
#include <algorithm>
#include <functional>
class TValue
{
private:
int m_n;
public:
TValue(int n = 0)
{
m_n = n;
printf("I am brith at %i\n", m_n);
}
~TValue()
{
printf("I am %i and dying\n", m_n);
}
void WhoIs()
{
printf("I am %i\n", m_n);
}
int Get(void) const {return m_n;}
int Get2(void) {return m_n;}
};
typedef boost::ptr_map<int, TValue>CMyMap;
bool Larger(const TValue& p1, const TValue& p2)
{
bool bRet = false;
bRet = (p2.Get() <= p1.Get() && (p2.Get()%2==0));
return bRet;
}
void TestCase1()
{
printf("\n\n======================TestCase
1:======================\n");
CMyMap mymap;
for(int i = 0; i < 10; ++i)
{
mymap.insert(i, new TValue(i));
}
std::stable_sort(mymap.begin(), mymap.end(), Larger);
}
int _tmain(int argc, _TCHAR* argv[])
{
TestCase1();
return 0;
}
}}}
--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/730#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:56 UTC