Boost logo

Boost Users :

Subject: [Boost-users] Including Xutil.h on Fedora breaks BOOST_FOREACH
From: Tron Thomas (tron.thomas_at_[hidden])
Date: 2009-05-22 16:02:26


Compiling this:

#include <X11/Xutil.h>
#include <boost/shared_ptr.hpp>
#include <vector>
#include <cstdlib>
#include <boost/foreach.hpp>
#include <iostream>
using std::ostream;

class Value
{
public:
explicit Value(int amount) : m_amount(amount) {}
void WriteTo(ostream& stream) const { stream << m_amount; }
private:
int m_amount;
};

ostream& operator <<(ostream& stream, const Value& value)
{
value.WriteTo(stream);
return stream;
}

int main()
{
typedef boost::shared_ptr<Value> ValuePtr;

std::vector<ValuePtr> valueBuffer;

for(int count = 0; 10 > count; ++count){
valueBuffer.push_back(ValuePtr(new Value(::rand())));
}

BOOST_FOREACH(ValuePtr value, valueBuffer){
std::cout << *value << std::endl;
}

return 0;
}

on Fedora 10 (Intel) produces error output like:

/usr/include/boost/foreach.hpp:223: error: expected
nested-name-specifier before ‘int’
/usr/include/boost/foreach.hpp:223: error: two or more data types in
declaration of ‘parameter’
/usr/include/boost/foreach.hpp:224: error: default template arguments
may not be used in function templates
Value.cpp: In function ‘int main()’:
Value.cpp:34: error: no matching function for call to
‘not_(boost::is_array<std::vector<boost::shared_ptr<Value>,
std::allocator<boost::shared_ptr<Value> > > >*)’
Value.cpp:34: error: no matching function for call to
‘not_(boost::foreach::is_noncopyable<std::vector<boost::shared_ptr<Value>,
std::allocator<boost::shared_ptr<Value> > > >*)’
Value.cpp:34: error: no matching function for call to
‘not_(boost::is_array<std::vector<boost::shared_ptr<Value>,
std::allocator<boost::shared_ptr<Value> > > >*)’
Value.cpp:34: error: no matching function for call to
‘not_(boost::foreach::is_noncopyable<std::vector<boost::shared_ptr<Value>,
std::allocator<boost::shared_ptr<Value> > > >*)’
Value.cpp:34: error: no matching function for call to
‘not_(boost::is_array<std::vector<boost::shared_ptr<Value>,
std::allocator<boost::shared_ptr<Value> > > >*)’
Value.cpp:34: error: no matching function for call to
‘not_(boost::foreach::is_noncopyable<std::vector<boost::shared_ptr<Value>,
std::allocator<boost::shared_ptr<Value> > > >*)’

If the first included header file is removed from the code, it builds
successfully.
Even though the code in this example doesn't technically need that first
header file included, it is representative of code that does.
What is needed so this code can build successfully while including all
the header files?


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