title: What is the time complexity of std::string::compare() in C++ function in C++?
body: <p>What will be the time complexity of <strong>std::string::compare()</strong> in C++?</p>
  <hr />
  <p>For example, if we have to check if the given input matches our required string or not -</p>
  <p>let say if we are taking origin as an input where Origin can be INDIAN or NON_INDIAN, we can do</p>
  <p>1.</p>
  <pre><code>if(origin == &quot;INDIAN&quot;){
      // our code
  }
  </code></pre>
  <p>OR</p>
  <p>2.</p>
  <pre><code>if(!origin.compare(&quot;INDIAN&quot;)){
      // our code
  }
  </code></pre>
  <hr />
  <p>The first method takes O(1) time, right?</p>
  <p>So I am wondering, How much time that compare function might be taking!
  <strong>Can anyone help me clear my doubt?</strong></p>