problems with templates

I

Ives Steglich

hi there

i have a line like:

boost::bind(&EventSource<SinkType>::fire<Op>,boost::ref(fireProc),_1)

and this generates an error like:

eventsource.h: In member function `void
Noja::Corba::EventSource<SinkType>::fireEvent(Op) const':
eventsource.h:119: error: expected primary-expression before '>' token
eventsource.h:119: error: expected primary-expression before ',' token

anybody some hints for me?
gcc: 3.4.1


greetings
dalini
 
V

Victor Bazarov

Ives Steglich said:
i have a line like:

boost::bind(&EventSource<SinkType>::fire<Op>,boost::ref(fireProc),_1)

and this generates an error like:

eventsource.h: In member function `void
Noja::Corba::EventSource<SinkType>::fireEvent(Op) const':
eventsource.h:119: error: expected primary-expression before '>' token
eventsource.h:119: error: expected primary-expression before ',' token

anybody some hints for me?

This line cannot generate just that error if it's the only line in the
translation unit. It would generate plenty of errors, beginning with
'boost' undefined.

Either post the complete compilable code or rephrase the question.

V
 
I

Ives Steglich

This line cannot generate just that error if it's the only line in the
translation unit. It would generate plenty of errors, beginning with
'boost' undefined.
Either post the complete compilable code or rephrase the question.

#ifndef EVENTSOURCE_H
#define EVENTSOURCE_H

#include "exceptions.h"
#include "debug.h"
#include "concurrency.h"


#include <list>
#include <algorithm>

#include <boost/bind.hpp>

#ifdef CURRENT_LOG_CATEGORY
#undef CURRENT_LOG_CATEGORY
#endif
#define CURRENT_LOG_CATEGORY 0x100ULL


namespace Noja
{
namespace Corba
{
template <class SinkType>
class EventSource
{
typedef typename SinkType::_var_type SinkVarType;
typedef typename SinkType::_ptr_type SinkPtrType;

std::list <SinkVarType> sinks;
mutable Mutex sinks_mutex;

template <class Op> static void fire(const Op
op, const SinkVarType sink)
{
try
{
DBG("Fire...");
op(sink);
DBG("Fire with no error");
}
catch (std::exception& ex)
{
ERROR("Caught std::exception: "
<< ex.what());
}
catch(CORBA::COMM_FAILURE& ex)
{
ERROR("System exception
(COMM_FAILURE),unable to contact the object.");
}
catch(CORBA::SystemException& ex)
{
std::string name=ex._name();
ERROR("Caught
CORBA::SystemException: " << name);
}
catch(CORBA::Exception& ex)
{
std::string name=ex._name();
ERROR("Caught
CORBA::Exception." << name);
}
catch(omniORB::fatalException& ex)
{
ERROR
(
"Caught
omniORB::fatalException thrown at position"
<<" file: "<<
ex.file()<<" line: " << ex.line() << " msg: " << ex.errmsg()
);
}
catch(...)
{
ERROR("Caught unknown exception.");
}
}

static bool is_nil(const SinkVarType obj)
{
DBG("testing for nil reference");
ASSERT_NOTNULL(obj.in());
return CORBA::is_nil(obj);
}

public:
void addSink(SinkPtrType sink)
{
Noja::Monitor<Noja::Mutex> mon(sinks_mutex);
DBG("copying sink");

SinkPtrType
sink_ptr=SinkType::_duplicate(sink);
SinkVarType sink_var=sink_ptr;
DBG("adding sink");
sinks.insert(sinks.end(),sink_var);
}

void removeSink(SinkPtrType sink)
{
Noja::Monitor<Noja::Mutex>
mon(sinks_mutex);
DBG("copying sink");
SinkVarType
sink_var=SinkType::_duplicate(sink);
DBG("removing sink");

std::remove(sinks.begin(),sinks.end(),sink_var);
}

void tidy()
{
Noja::Monitor<Noja::Mutex>
mon(sinks_mutex);
DBG("removing all NIL
(#"<<sinks.size()<<")");

std::remove_if(sinks.begin(),sinks.end(),is_nil);
DBG("after remove NIL: #"<<sinks.size());
}

template <class Op> void fireEvent(const Op
fireProc) const
{
Noja::Monitor<Noja::Mutex>
mon(sinks_mutex);

DBG("fireing events to
#"<<sinks.size()<<" sinks");
if(!sinks.empty())
std::for_each
(
sinks.begin(),
sinks.end(),

boost::bind(&EventSource<SinkType>::fire<Op>,boost::ref(fireProc),_1)
);
DBG("no error while fireing events");
}
};
}
}

#endif
 
I

Ives Steglich

Victor said:
This line cannot generate just that error if it's the only line in the
translation unit. It would generate plenty of errors, beginning with
'boost' undefined.

Either post the complete compilable code or rephrase the question.
so i posted the code and the problem actually is, with gcc 3.4 oder 3.3
it would compile with 3.4.1 not - the 3.4 and 3.3 are used on a debian
system, the 3.4.1 is used on a fc3 system...

so are there changes in typechecking or somthing in gcc from 3.4 to
3.4.1? which may induce such an error?

since it looks like either SingType but more probably at <OP> the OP
evaluates to nothing somehow, sow the compiler dies? since <> isn't that
usefull?

so that's somehow confusing a bit...


greetings
dalini
 
V

Victor Bazarov

Ives said:
so i posted the code

One of the points of posting the code is so that we could take it and
shove it onto our compilers (often different from yours) and see how
they react. That's not necessarily to prove the code is correct or
incorrect. However, the code you posted contains #include directives
with headers you didn't supply. Oh well...
and the problem actually is, with gcc 3.4 oder 3.3
it would compile with 3.4.1 not - the 3.4 and 3.3 are used on a debian
system, the 3.4.1 is used on a fc3 system...

so are there changes in typechecking or somthing in gcc from 3.4 to
3.4.1? which may induce such an error?

Well, that I don't know, gnu.g++.help would be the right newsgroup for
that (or use their web forums). BTW, what do their release notes say?
since it looks like either SingType but more probably at <OP> the OP
evaluates to nothing somehow, sow the compiler dies? since <> isn't that
usefull?

You could try splitting the line in several places to know for sure which
since said:
so that's somehow confusing a bit...

I bet.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,578
Latest member
LC_06

Latest Threads

Top