Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-25430

std::pair error: no matching constructor for initialization of 'pair<int, int>'

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • Qt Creator 4.12.4
    • C/C++/Obj-C++ Support
    • None
    • MSVC 2015
    • Windows

    Description

      我认为这应该是语法检查的BUG。
      It may be a false alarm of semantic check caused by clang-model.

      // code placeholder
      #include <iostream>
      using namespace std;
      
      int main()
      {
          /*
           *All code can compile and work.
          */
          /*Semantic Issue
           *main.cpp:12:19: error: no matching constructor for initialization of 'pair<int, int>'
           *utility:271:5: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
           *utility:212:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided
           *utility:129:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
          */
          pair<int,int> p1(10,25);
          pair<int,float> p2(20,50.5f);
          pair<double,string> p3(2.0e5,"cd");
          cout<<p1.first<<" "<<p1.second<<endl;//output is right.
          cout<<p2.first<<" "<<p2.second<<endl;//output is right.
          cout<<p3.first<<" "<<p3.second<<endl;//output is right.
          return 0;
      }
      

       

      Attachments

        1. main.cpp
          0.6 kB
        2. main-1.cpp
          0.9 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kandeler Christian Kandeler
            ihmosky ihmosky
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes