Strange multimap Error

Source: Internet
Author: User
Tags traits

 

Using namespace STD; <br/> multimap <string, string> mtmptest; <br/> pair <string, string> pairtest = make_pair ("D", "Du "); <br/> mtmptest. insert (pairtest); <br/> 

 

This code is written in imitation books. However, compilation and translation fail. There are a lot of compilation errors. The compilation errors are as follows:

 

 

 

1> ------ build started: Project: dialogtest, configuration: Debug Win32 ------

1> compiling...

1> dialogtestdlg. cpp

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: _ tree <_ traits> &, const STD: _ tree <_ traits> &) ': cocould not deduce template argument for 'const STD :: _ tree <_ traits> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xtree (1466): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (142): while compiling class template member function 'bool STD: less <_ ty> :: operator () (const _ ty &, const _ ty &) const'

1>

1> [

1> _ ty = STD: String

1>]

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/Map (68): see reference to class template instantiation 'std: less <_ ty> 'being compiled

1>

1> [

1> _ ty = STD: String

1>]

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xtree (22): see reference to class template instantiation 'std: _ tmap_traits <_ KTY, _ ty, _ PR, _ alloc, _ MFL> 'being compiled

1>

1> [

1> _ KTY = STD: string,

1> _ ty = STD: string,

1> _ Pr = STD: less <STD: String>,

1> _ alloc = STD: Allocator <STD: pair <const STD: String, STD: String>,

1> _ MFL = true

1>]

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xtree (63): see reference to class template instantiation 'std :: _ tree_nod <_ traits> 'being compiled

1>

1> [

1> _ traits = STD: _ tmap_traits <STD: String, STD: String, STD: less <STD: String>, STD: Allocator <STD :: pair <const STD: String, STD: String >>, true>

1>]

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xtree (89): see reference to class template instantiation 'std :: _ tree_ptr <_ traits> 'being compiled

1>

1> [

1> _ traits = STD: _ tmap_traits <STD: String, STD: String, STD: less <STD: String>, STD: Allocator <STD :: pair <const STD: String, STD: String >>, true>

1>]

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xtree (107): see reference to class template instantiation 'std :: _ tree_val <_ traits> 'being compiled

1>

1> [

1> _ traits = STD: _ tmap_traits <STD: String, STD: String, STD: less <STD: String>, STD: Allocator <STD :: pair <const STD: String, STD: String >>, true>

1>]

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/Map (203): see reference to class template instantiation 'std :: _ tree <_ traits> 'being compiled

1>

1> [

1> _ traits = STD: _ tmap_traits <STD: String, STD: String, STD: less <STD: String>, STD: Allocator <STD :: pair <const STD: String, STD: String >>, true>

1>]

1> C:/Documents and Settings/admin/dialogtest/dialogtestdlg. CPP (166): see reference to class template instantiation 'std: multimap <_ KTY, _ ty> 'being compiled

1>

1> [

1> _ KTY = STD: string,

1> _ ty = STD: String

1>]

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: _ tree <_ traits> &, const STD: _ tree <_ traits> &) ': cocould not deduce template argument for 'const STD :: _ tree <_ traits> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xtree (1466): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: _ tree <_ traits> &, const STD: _ tree <_ traits> &) ': cocould not deduce template argument for 'const STD :: _ tree <_ traits> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xtree (1466): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: _ tree <_ traits> &, const STD: _ tree <_ traits> &) ': cocould not deduce template argument for 'const STD :: _ tree <_ traits> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xtree (1466): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: queue <_ ty, _ container> &, const STD: queue <_ ty, _ container> &) ': cocould not deduce template argument for 'const STD :: queue <_ ty, _ container> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/Queue (107): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: queue <_ ty, _ container> &, const STD: queue <_ ty, _ container> &) ': cocould not deduce template argument for 'const STD :: queue <_ ty, _ container> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/Queue (107): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: queue <_ ty, _ container> &, const STD: queue <_ ty, _ container> &) ': cocould not deduce template argument for 'const STD :: queue <_ ty, _ container> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/Queue (107): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: queue <_ ty, _ container> &, const STD: queue <_ ty, _ container> &) ': cocould not deduce template argument for 'const STD :: queue <_ ty, _ container> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/Queue (107): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: stack <_ ty, _ container> &, const STD: Stack <_ ty, _ container> &) ': cocould not deduce template argument for 'const STD :: stack <_ ty, _ container> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/stack (94): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: stack <_ ty, _ container> &, const STD: Stack <_ ty, _ container> &) ': cocould not deduce template argument for 'const STD :: stack <_ ty, _ container> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/stack (94): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: stack <_ ty, _ container> &, const STD: Stack <_ ty, _ container> &) ': cocould not deduce template argument for 'const STD :: stack <_ ty, _ container> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/stack (94): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: stack <_ ty, _ container> &, const STD: Stack <_ ty, _ container> &) ': cocould not deduce template argument for 'const STD :: stack <_ ty, _ container> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/stack (94): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: deque <_ ty, _ alloc> &, const STD: deque <_ ty, _ alloc> &) ': cocould not deduce template argument for 'const STD :: deque <_ ty, _ alloc> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/deque (1354): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: deque <_ ty, _ alloc> &, const STD: deque <_ ty, _ alloc> &) ': cocould not deduce template argument for 'const STD :: deque <_ ty, _ alloc> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/deque (1354): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: deque <_ ty, _ alloc> &, const STD: deque <_ ty, _ alloc> &) ': cocould not deduce template argument for 'const STD :: deque <_ ty, _ alloc> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/deque (1354): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: deque <_ ty, _ alloc> &, const STD: deque <_ ty, _ alloc> &) ': cocould not deduce template argument for 'const STD :: deque <_ ty, _ alloc> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/deque (1354): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: vector <_ ty, _ alloc> &, const STD: vector <_ ty, _ alloc> &) ': cocould not deduce template argument for 'const STD :: vector <_ ty, _ alloc> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/vector (1320): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: vector <_ ty, _ alloc> &, const STD: vector <_ ty, _ alloc> &) ': cocould not deduce template argument for 'const STD :: vector <_ ty, _ alloc> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/vector (1320): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: vector <_ ty, _ alloc> &, const STD: vector <_ ty, _ alloc> &) ': cocould not deduce template argument for 'const STD :: vector <_ ty, _ alloc> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/vector (1320): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: vector <_ ty, _ alloc> &, const STD: vector <_ ty, _ alloc> &) ': cocould not deduce template argument for 'const STD :: vector <_ ty, _ alloc> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/vector (1320): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: reverse_iterator <_ ranit> &, const STD: reverse_iterator <_ ranit2> &) ': cocould not deduce template argument for 'const STD :: reverse_iterator <_ ranit> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xutility (2236): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: reverse_iterator <_ ranit> &, const STD: reverse_iterator <_ ranit2> &) ': cocould not deduce template argument for 'const STD :: reverse_iterator <_ ranit> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xutility (2236): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: reverse_iterator <_ ranit> &, const STD: reverse_iterator <_ ranit2> &) ': cocould not deduce template argument for 'const STD :: reverse_iterator <_ ranit> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xutility (2236): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: reverse_iterator <_ ranit> &, const STD: reverse_iterator <_ ranit2> &) ': cocould not deduce template argument for 'const STD :: reverse_iterator <_ ranit> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xutility (2236): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: _ revranit <_ ranit, _ base> &, const STD: _ revranit <_ ranit2, _ base2> &) ': cocould not deduce template argument for 'const STD :: _ revranit <_ ranit, _ base> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xutility (2046): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: _ revranit <_ ranit, _ base> &, const STD: _ revranit <_ ranit2, _ base2> &) ': cocould not deduce template argument for 'const STD :: _ revranit <_ ranit, _ base> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xutility (2046): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: _ revranit <_ ranit, _ base> &, const STD: _ revranit <_ ranit2, _ base2> &) ': cocould not deduce template argument for 'const STD :: _ revranit <_ ranit, _ base> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xutility (2046): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: _ revranit <_ ranit, _ base> &, const STD: _ revranit <_ ranit2, _ base2> &) ': cocould not deduce template argument for 'const STD :: _ revranit <_ ranit, _ base> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/xutility (2046): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: pair <_ ty1, _ ty2> &, const STD: pair <_ ty1, _ ty2> &) ': cocould not deduce template argument for 'const STD :: pair <_ ty1, _ ty2> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/utility (84): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: pair <_ ty1, _ ty2> &, const STD: pair <_ ty1, _ ty2> &) ': cocould not deduce template argument for 'const STD :: pair <_ ty1, _ ty2> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/utility (84): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: pair <_ ty1, _ ty2> &, const STD: pair <_ ty1, _ ty2> &) ': cocould not deduce template argument for 'const STD :: pair <_ ty1, _ ty2> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/utility (84): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2784: 'bool STD: Operator <(const STD :: pair <_ ty1, _ ty2> &, const STD: pair <_ ty1, _ ty2> &) ': cocould not deduce template argument for 'const STD :: pair <_ ty1, _ ty2> & 'from 'const STD: string'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/utility (84): See Declaration of 'std: Operator <'

1> C:/program files/Microsoft Visual Studio 9.0/VC/include/functional (143): Error c2676: Binary '<': 'const STD :: string 'does not define this operator or a conversion to a type acceptable to the predefined Operator

1> build log was saved at "file: // C:/Documents and Settings/admin/zookeeper without program execution/Vs 2008 test/dialogtest/debug/buildlog.htm"

1> dialogtest-33 error (s), 0 warning (s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========

 

My head is big .. How can there be so many mistakes in a few simple sentences. After Google (goolge is really a good thing), there was no # include <string> problem. I used to think that # include <iostream> is not needed. After the problem is solved, in order to understand why, Google again (again, Google is really nice) and found the following conclusion:

 

1. <string> is the c ++ header file of STD, corresponding to the new strng class.
2. <iostream> is the header file containing input/output stream processing.

 

Oh, yes. There is a big difference between. h and. h .. <String. h> is the old c header file, which corresponds to a char *-based string processing function; the newly defined methods in C ++ all have namespaces. For example, cout belongs to STD namespace. If the include header file is added. h. Using namespace is used by default. Otherwise, you need to add using namespace XXX to the methods defined in C, such as printf.

Iostream. H is the header file containing input/output stream processing. iostream is nothing.
However, iostream requires a namespace.

# Include <iostream. h>
Or
# Include <iostream>
Using namespace STD;
Both.

# Include <iostream. h> is common in C.
# Include <iostream>
Using namespace STD;
It's more common in C ++. Of course, this kind of change is not coming out of the head of a person. The story is tortuous ,,, it also reflects the differences and history between C and C ++. If you are interested, You can Google it yourself.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.