C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

compile error with Boost Function object and templated funct

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Faheem Mitha
Guest





PostPosted: Sat Aug 26, 2006 9:10 am    Post subject: compile error with Boost Function object and templated funct Reply with quote



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 dim> int foo(void)
{
boost::function<int ()> choice;
choice = &rchoice<dim>;
return choice();
}

int main()
{
return foo<2>();
}
***************************************************************
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.