“Call to std::pair is ambiguous” by Clion but code can be compiled












2















I have a function that compiles in this state but gives "Call to pair is ambiguous" but only in Clion IDE, compiles without problem and the warning dissapears if i add whatever random thing, even if it ends up causing compiler error.



std::pair<Status, std::set<std::string>> Config::foo(const std::string &sec, const std::string &key) const {

return std::pair<Status, std::set<std::string>>(
hasSection(sec) ? (hasKey(sec, key) ? Status::Success
: Status::MissingKey)
: Status::MissingSec ,
hasKey(sec, key) ? config_map.find(sec)->second.find(key)->second
: std::set<std::string>()
);
}


I have no idea how to fix it, or even what the problem actually is.










share|improve this question





























    2















    I have a function that compiles in this state but gives "Call to pair is ambiguous" but only in Clion IDE, compiles without problem and the warning dissapears if i add whatever random thing, even if it ends up causing compiler error.



    std::pair<Status, std::set<std::string>> Config::foo(const std::string &sec, const std::string &key) const {

    return std::pair<Status, std::set<std::string>>(
    hasSection(sec) ? (hasKey(sec, key) ? Status::Success
    : Status::MissingKey)
    : Status::MissingSec ,
    hasKey(sec, key) ? config_map.find(sec)->second.find(key)->second
    : std::set<std::string>()
    );
    }


    I have no idea how to fix it, or even what the problem actually is.










    share|improve this question



























      2












      2








      2








      I have a function that compiles in this state but gives "Call to pair is ambiguous" but only in Clion IDE, compiles without problem and the warning dissapears if i add whatever random thing, even if it ends up causing compiler error.



      std::pair<Status, std::set<std::string>> Config::foo(const std::string &sec, const std::string &key) const {

      return std::pair<Status, std::set<std::string>>(
      hasSection(sec) ? (hasKey(sec, key) ? Status::Success
      : Status::MissingKey)
      : Status::MissingSec ,
      hasKey(sec, key) ? config_map.find(sec)->second.find(key)->second
      : std::set<std::string>()
      );
      }


      I have no idea how to fix it, or even what the problem actually is.










      share|improve this question
















      I have a function that compiles in this state but gives "Call to pair is ambiguous" but only in Clion IDE, compiles without problem and the warning dissapears if i add whatever random thing, even if it ends up causing compiler error.



      std::pair<Status, std::set<std::string>> Config::foo(const std::string &sec, const std::string &key) const {

      return std::pair<Status, std::set<std::string>>(
      hasSection(sec) ? (hasKey(sec, key) ? Status::Success
      : Status::MissingKey)
      : Status::MissingSec ,
      hasKey(sec, key) ? config_map.find(sec)->second.find(key)->second
      : std::set<std::string>()
      );
      }


      I have no idea how to fix it, or even what the problem actually is.







      c++ windows clion






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 8:44









      jww

      53.9k40232508




      53.9k40232508










      asked Nov 2 '17 at 1:00









      Zerg OvermindZerg Overmind

      1376




      1376
























          1 Answer
          1






          active

          oldest

          votes


















          1














          If you want constructs a pair object, you have to use std::make_pair function template.



          template <class T1, class T2>
          pair<V1,V2> make_pair (T1&& x, T2&& y);



          The template types can be implicitly deduced from the arguments passed to make_pair.



           return std::make_pair(
          hasSection(sec) ? (hasKey(sec, key) ? Status::Success
          : Status::MissingKey)
          : Status::MissingSec ,
          hasKey(sec, key) ? config_map.find(sec)->second.find(key)->second :
          std::set<std::string>()
          );


          This code compile without "Call to pair is ambiguous".



          If you specify the make_pair template type, you encounter an error of the type "Expression must be rvalue".






          share|improve this answer
























          • Please be clear about what the problem actually is

            – Welton122
            Nov 8 '17 at 20:15











          • Zerg's code is correct, "Call to pair is ambiguous" is essentially a CLion bug. std::pair has an initialization constructor that you use it so "std::pair <std::string,int> example("example",2);". std::make_pair, instead, build std::pair object using r-value and move constructor (and implicit conversion).

            – S. Martelli
            Nov 10 '17 at 10:56













          • I'd rather return { a, b };.

            – Marc Glisse
            Nov 22 '18 at 8:47











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47065971%2fcall-to-stdpair-is-ambiguous-by-clion-but-code-can-be-compiled%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          If you want constructs a pair object, you have to use std::make_pair function template.



          template <class T1, class T2>
          pair<V1,V2> make_pair (T1&& x, T2&& y);



          The template types can be implicitly deduced from the arguments passed to make_pair.



           return std::make_pair(
          hasSection(sec) ? (hasKey(sec, key) ? Status::Success
          : Status::MissingKey)
          : Status::MissingSec ,
          hasKey(sec, key) ? config_map.find(sec)->second.find(key)->second :
          std::set<std::string>()
          );


          This code compile without "Call to pair is ambiguous".



          If you specify the make_pair template type, you encounter an error of the type "Expression must be rvalue".






          share|improve this answer
























          • Please be clear about what the problem actually is

            – Welton122
            Nov 8 '17 at 20:15











          • Zerg's code is correct, "Call to pair is ambiguous" is essentially a CLion bug. std::pair has an initialization constructor that you use it so "std::pair <std::string,int> example("example",2);". std::make_pair, instead, build std::pair object using r-value and move constructor (and implicit conversion).

            – S. Martelli
            Nov 10 '17 at 10:56













          • I'd rather return { a, b };.

            – Marc Glisse
            Nov 22 '18 at 8:47
















          1














          If you want constructs a pair object, you have to use std::make_pair function template.



          template <class T1, class T2>
          pair<V1,V2> make_pair (T1&& x, T2&& y);



          The template types can be implicitly deduced from the arguments passed to make_pair.



           return std::make_pair(
          hasSection(sec) ? (hasKey(sec, key) ? Status::Success
          : Status::MissingKey)
          : Status::MissingSec ,
          hasKey(sec, key) ? config_map.find(sec)->second.find(key)->second :
          std::set<std::string>()
          );


          This code compile without "Call to pair is ambiguous".



          If you specify the make_pair template type, you encounter an error of the type "Expression must be rvalue".






          share|improve this answer
























          • Please be clear about what the problem actually is

            – Welton122
            Nov 8 '17 at 20:15











          • Zerg's code is correct, "Call to pair is ambiguous" is essentially a CLion bug. std::pair has an initialization constructor that you use it so "std::pair <std::string,int> example("example",2);". std::make_pair, instead, build std::pair object using r-value and move constructor (and implicit conversion).

            – S. Martelli
            Nov 10 '17 at 10:56













          • I'd rather return { a, b };.

            – Marc Glisse
            Nov 22 '18 at 8:47














          1












          1








          1







          If you want constructs a pair object, you have to use std::make_pair function template.



          template <class T1, class T2>
          pair<V1,V2> make_pair (T1&& x, T2&& y);



          The template types can be implicitly deduced from the arguments passed to make_pair.



           return std::make_pair(
          hasSection(sec) ? (hasKey(sec, key) ? Status::Success
          : Status::MissingKey)
          : Status::MissingSec ,
          hasKey(sec, key) ? config_map.find(sec)->second.find(key)->second :
          std::set<std::string>()
          );


          This code compile without "Call to pair is ambiguous".



          If you specify the make_pair template type, you encounter an error of the type "Expression must be rvalue".






          share|improve this answer













          If you want constructs a pair object, you have to use std::make_pair function template.



          template <class T1, class T2>
          pair<V1,V2> make_pair (T1&& x, T2&& y);



          The template types can be implicitly deduced from the arguments passed to make_pair.



           return std::make_pair(
          hasSection(sec) ? (hasKey(sec, key) ? Status::Success
          : Status::MissingKey)
          : Status::MissingSec ,
          hasKey(sec, key) ? config_map.find(sec)->second.find(key)->second :
          std::set<std::string>()
          );


          This code compile without "Call to pair is ambiguous".



          If you specify the make_pair template type, you encounter an error of the type "Expression must be rvalue".







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 '17 at 20:13









          S. MartelliS. Martelli

          1921




          1921













          • Please be clear about what the problem actually is

            – Welton122
            Nov 8 '17 at 20:15











          • Zerg's code is correct, "Call to pair is ambiguous" is essentially a CLion bug. std::pair has an initialization constructor that you use it so "std::pair <std::string,int> example("example",2);". std::make_pair, instead, build std::pair object using r-value and move constructor (and implicit conversion).

            – S. Martelli
            Nov 10 '17 at 10:56













          • I'd rather return { a, b };.

            – Marc Glisse
            Nov 22 '18 at 8:47



















          • Please be clear about what the problem actually is

            – Welton122
            Nov 8 '17 at 20:15











          • Zerg's code is correct, "Call to pair is ambiguous" is essentially a CLion bug. std::pair has an initialization constructor that you use it so "std::pair <std::string,int> example("example",2);". std::make_pair, instead, build std::pair object using r-value and move constructor (and implicit conversion).

            – S. Martelli
            Nov 10 '17 at 10:56













          • I'd rather return { a, b };.

            – Marc Glisse
            Nov 22 '18 at 8:47

















          Please be clear about what the problem actually is

          – Welton122
          Nov 8 '17 at 20:15





          Please be clear about what the problem actually is

          – Welton122
          Nov 8 '17 at 20:15













          Zerg's code is correct, "Call to pair is ambiguous" is essentially a CLion bug. std::pair has an initialization constructor that you use it so "std::pair <std::string,int> example("example",2);". std::make_pair, instead, build std::pair object using r-value and move constructor (and implicit conversion).

          – S. Martelli
          Nov 10 '17 at 10:56







          Zerg's code is correct, "Call to pair is ambiguous" is essentially a CLion bug. std::pair has an initialization constructor that you use it so "std::pair <std::string,int> example("example",2);". std::make_pair, instead, build std::pair object using r-value and move constructor (and implicit conversion).

          – S. Martelli
          Nov 10 '17 at 10:56















          I'd rather return { a, b };.

          – Marc Glisse
          Nov 22 '18 at 8:47





          I'd rather return { a, b };.

          – Marc Glisse
          Nov 22 '18 at 8:47




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47065971%2fcall-to-stdpair-is-ambiguous-by-clion-but-code-can-be-compiled%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()