473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

compile error with Boost Function object and templated function (Intel C++ compiler)

Hi,

The following bit of code compiles fine with gcc 3.3 or later, but has
problems with the Intel C++ compiler version 9.1, which produces the
following error message.

Is this a compiler bug, or is there something wrong with the code?

If the former, I'd be grateful for suggestions of a workaround, and if
the latter, please tell me what I'm doing wrong.

Note that the corresponding version with no templates compiles without
problems.

Thanks in advance. Faheem.

************************************************** ************************

icpc -o foo.o -c -Wall -Werror -g -wd383,810,981,1418 cxxlib-icc
-DBOOST_RAND -I/usr/local/include/boost-1_33_1 \foo.cpp

foo.cpp(12): error: no operator "=" matches these operands operand
types are: boost::function<int (), std::allocator<void>=
<unknown-type>
choice = &rchoice<dim>;
^
************************************************** ***********
#include <boost/function.hpp>

template<int dim>
int rchoice()
{
return 1;
}

template<int dimint foo(void)
{
boost::function<int ()choice;
choice = &rchoice<dim>;
return choice();
}

int main()
{
return foo<2>();
}
************************************************** *************
Aug 26 '06 #1
2 2608
Faheem Mitha wrote:
Hi,

The following bit of code compiles fine with gcc 3.3 or later, but has
problems with the Intel C++ compiler version 9.1, which produces the
following error message.

Is this a compiler bug, or is there something wrong with the code?

If the former, I'd be grateful for suggestions of a workaround, and if
the latter, please tell me what I'm doing wrong.

Note that the corresponding version with no templates compiles without
problems.

Thanks in advance. Faheem.

************************************************** ************************

icpc -o foo.o -c -Wall -Werror -g -wd383,810,981,1418 cxxlib-icc
-DBOOST_RAND -I/usr/local/include/boost-1_33_1 \foo.cpp

foo.cpp(12): error: no operator "=" matches these operands operand
types are: boost::function<int (), std::allocator<void>=
<unknown-type>
choice = &rchoice<dim>;
^
************************************************** ***********
#include <boost/function.hpp>

template<int dim>
int rchoice()
{
return 1;
}

template<int dimint foo(void)
{
boost::function<int ()choice;
choice = &rchoice<dim>;
return choice();
}

int main()
{
return foo<2>();
}
************************************************** *************
Changing the header to <functionaland boost::function to
std::tr1::function, the code compiles fine at Dinkum's online test with
both MS VC++8 and EDG, so I'd say it's an Intel problem. In that case,
you'll want to post to a compiler-specific newsgroup or forum (in your
case, something to do with Intel's compiler) for a work-around (see
http://www.parashift.com/c++-faq-lit....html#faq-5.9).

Cheers! --M

Aug 26 '06 #2
On 26 Aug 2006 10:11:03 -0700, mlimber <ml*****@gmail.comwrote:
Changing the header to <functionaland boost::function to
std::tr1::function, the code compiles fine at Dinkum's online test
with both MS VC++8 and EDG, so I'd say it's an Intel problem. In
that case, you'll want to post to a compiler-specific newsgroup or
forum (in your case, something to do with Intel's compiler) for a
work-around (see
http://www.parashift.com/c++-faq-lit....html#faq-5.9).
Thanks for the information. I don't quite get the bit about changing
the header and boost::function, but if it is really a compiler bug,
that is unfortunate.

Faheem.
Aug 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: frankg | last post by:
When I compile this file ------------------------------------------------------ #include <stdarg.h> template <class Any> void var_arg_func(int dimension_count, ...) { int dimensions;...
5
by: Lars Schouw | last post by:
I have downloaded the newest boos release. I am havng problems building boost using the intel C++ 8.0 compiler. It looks as if bjam can't fine the icl.exe compiler executable itself. This file is...
3
by: Jim West | last post by:
The following code compiles and executes properly on one compiler (GNU C++) but not on another (Intel C++ V8.1). Which compiler is correct? If my code is improper (that is, the Intel compiler is...
2
by: Frank Vanris | last post by:
Hi, I am using boost which uses templates heavily. When I make a typo the compiler complains, but it complains in the boost headerfile (I attached an example at the end where I forgot to pass in...
0
by: ufnuceda | last post by:
Hello everyone, I was wondering if any of you have some experience with the boost library. I am having trouble compiling code with it. Since boost is being used a lot these days I thought some...
4
by: silverburgh.meryl | last post by:
I have code which uses Boost lambda in a template like this: using namespace boost::lambda; template<class T> bool lessThanXY( T& src, T& dest ) { return (src.getY() < dest.getY()); } ...
2
by: newbie | last post by:
I happened to read boost library code and realized that most (the part I read) functions are inlined like: template <class Key> inline void Foo(const Key& k) { ... ... } Is there a strong...
5
by: mackenzie | last post by:
Hello, I am looking for a little bit of help. I am trying to create a dynamically allocated object which contains one or more objects of type boost::pool<>. I get a compiler error when an object...
3
by: alishapal | last post by:
Hi there So I am getting these error messages from Intel (v10) and g++ (v4.1.2) compilers respectively: "error: the object has cv-qualifiers that are not compatible with the member function. object...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.