Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > xServices::CServices<TImp>::StHoldClientList::StHo ldClientList(std::set<TImp*, std::less<TImp*>, std::allocator<TImp*> >&)':

Reply
Thread Tools

xServices::CServices<TImp>::StHoldClientList::StHo ldClientList(std::set<TImp*, std::less<TImp*>, std::allocator<TImp*> >&)':

 
 
Vinu
Guest
Posts: n/a
 
      07-06-2005
Hi
I am facing a problem in compilation the error is like this

In constructor
xServices::CServices<TImp>::StHoldClientList::StHo ldClientList(std::set<TImp*,
std::less<TImp*>, std::allocator<TImp*> >&)':
: error: expected `;' before "pos"
: error: `pos' undeclared (first use this function)
: error: (Each undeclared identifier is reported only once for each
function it appears in.)
: In destructor
`xServices::CServices<TImp>::StHoldClientList::~St HoldClientList()':
: error: expected `;' before "pos"
: error: `pos' undeclared (first use this function)


Source Code:

namespace xServices
{

template <class TImp>
class CServices
{
protected:
typedef typename std::set<TImp*> ServiceList;
typedef typename ServiceList::iterator ServiceIterator;
ServiceList m_list;
struct StHoldClientList
{
StHoldClientList(ServiceList& clients)
: m_clients(clients)
{
for (CServices::ServiceIterator pos = m_clients.begin(); pos !=
m_clients.end(); ++pos)
(*pos)->AddRef();
}
~StHoldClientList()
{
for (CServices::ServiceIterator pos = m_clients.begin(); pos !=
m_clients.end(); ++pos)
(*pos++)->Release();
}
ServiceList& m_clients;
};
friend struct StHoldClientList;
};
}


Can u help me to solve this error.
Can you suggest standard way of doing it on Sun Solaris Sparc? We are
using gcc 3.4.2 .


Thanks
Vinu

 
Reply With Quote
 
 
 
 
titancipher
Guest
Posts: n/a
 
      07-06-2005
Try moving the declaration of the ServiceIterator pos out of the
for-loop.

Incidentally, check your destructor, it appears you may be incrementing
'pos' twice, once in the Release, and once for each loop.

 
Reply With Quote
 
 
 
 
Vinu
Guest
Posts: n/a
 
      07-06-2005


I tried the for - loop option what u specified but still it is giving
error and ur next suggestion ,I think it will not affect at compilation


Thanks
Vinu

 
Reply With Quote
 
titancipher
Guest
Posts: n/a
 
      07-06-2005
It compiles with gcc, so I am not certain what your error is. It may
be the sun compiler. Try changing ServiceIterator to:

std::set<TImp*>::iterator pos

Also, yes, the pos increment would be a run-time memory leak, not a
compilation problem.

 
Reply With Quote
 
Jim Langston
Guest
Posts: n/a
 
      07-07-2005

"Vinu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi
> I am facing a problem in compilation the error is like this
>
> In constructor
> xServices::CServices<TImp>::StHoldClientList::StHo ldClientList(std::set<TImp*,
> std::less<TImp*>, std::allocator<TImp*> >&)':
> : error: expected `;' before "pos"
> : error: `pos' undeclared (first use this function)
> : error: (Each undeclared identifier is reported only once for each
> function it appears in.)
> : In destructor
> `xServices::CServices<TImp>::StHoldClientList::~St HoldClientList()':
> : error: expected `;' before "pos"
> : error: `pos' undeclared (first use this function)
>
>
> Source Code:
>
> namespace xServices
> {
>
> template <class TImp>
> class CServices
> {
> protected:
> typedef typename std::set<TImp*> ServiceList;
> typedef typename ServiceList::iterator ServiceIterator;
> ServiceList m_list;
> struct StHoldClientList
> {
> StHoldClientList(ServiceList& clients)
> : m_clients(clients)
> {
> for (CServices::ServiceIterator pos = m_clients.begin(); pos !=
> m_clients.end(); ++pos)
> (*pos)->AddRef();
> }
> ~StHoldClientList()
> {
> for (CServices::ServiceIterator pos = m_clients.begin(); pos !=
> m_clients.end(); ++pos)
> (*pos++)->Release();
> }
> ServiceList& m_clients;
> };
> friend struct StHoldClientList;
> };
> }
>
>
> Can u help me to solve this error.
> Can you suggest standard way of doing it on Sun Solaris Sparc? We are
> using gcc 3.4.2 .
>
>
> Thanks
> Vinu


try this:

CServices::ServiceIterator pos;
for (pos = m_clients.begin(); pos != m_clients.end(); ++pos)
(*pos)->AddRef();


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments