Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

std::pair Causing Compilation Errors

Gennadiy_Rishkin
Beginner
1,773 Views
Hi,
I just installed the Intel C++ Composer XE 2011. I've replaced all TR1 usage in my code with the Boost versions. However, std::pair is causing me problems.
The line of code is:
myMap.insert( std::pair( boost::make_tuple(x, y, z), boost::make_tuple(A, B, C) ) );
Tuple is a typedef:
typedef boost::tuple Tuple;
myMap is a std:map:
std::map Map;
These all worked fine with gcc.
How can I resolve this?
The error I get is:
main.cpp(776): error: argument list for class template "std::pair" is missing
myMap.insert( std::pair( boost::make_tuple(x, y, z), boost::make_tuple(A, B, C) ) );
^
detected during instantiation of "void Foo::run() [with dim=3]" at line 1163
/usr/include/c++/4.4.3/bits/stl_function.h(230): error: no operator "<" matches these operands
operand types are: const Tuple < const Tuple
{ return __x < __y; }
^
detected during:
instantiation of "bool std::less<_Tp>::operator()(const _Tp &, const _Tp &) const [with _Tp=Tuple]" at line 1170 of "/usr/include/c++/4.4.3/bits/stl_tree.h"
instantiation of "std::pair<:_RB_TREE_ITERATOR><_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(const _Val &) [with _Key=Tuple, _Val=std::pair, _KeyOfValue=std::_Select1st<:PAIR>>, _Compare=std::less, _Alloc=std::allocator<:PAIR>>]" at line 500 of "/usr/include/c++/4.4.3/bits/stl_map.h"
instantiation of "std::pair<:_RB_TREE><_Key, std::pair, std::_Select1st<:PAIR>>, _Compare, _Alloc::rebind<:PAIR>>::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(const std::pair &) [with _Key=Tuple, _Tp=Tuple, _Compare=std::less, _Alloc=std::allocator<:PAIR>>]" at line 776 of "main.cpp"
instantiation of "void Foo::setup_system() [with dim=3]" at line 1069 of "main.cpp"
instantiation of "void Foo::run() [with dim=3]" at line 1163 of "main.cpp"
compilation aborted for main.cpp (code 2)
Many thanks,
Gennadiy
0 Kudos
2 Replies
Lingfeng_C_Intel
Employee
1,773 Views
Hi Rishkin,

If you want to use boost library with Intel C/C++, you have to build boost library using Intel C/C++ first. As you've known that boost will use the same library for project. For example, boost will call MS library if the project is built with MS VC etc.

Thanks,
Wise
0 Kudos
Judith_W_Intel
Employee
1,773 Views

You say this line of code is causing the error:

> The line of code is:
> myMap.insert( std::pair( boost::make_tuple(x, y, z), boost::make_tuple(A, B, C) ) );

and yet the error messageshows that the actual line is different:

> main.cpp(776): error: argument list for class template "std::pair" is missing
> myMap.insert( std::pair( boost::make_tuple(x, y, z), boost::make_tuple(A, B, C) ) );

Notice in the error message there is no explicit template argument list for std::pair.

Anyway if you can create a preprocessed file that compiles withg++ but not with our compiler please attach it. Use the -E option to create the file.

thanks
Judy
0 Kudos
Reply