title: "Use of operator + is ambiguous", although type cast is declared as explicit
body: <p>I' ve been trying to make a small library for working with big integers, just as practice, but I get this error for no apparent reason: </p>
  
  <blockquote>
    <p>Use of overloaded operator '+' is ambiguous (with operand types 'BigNum::BigInt' and 'int')</p>
  </blockquote>
  
  <p>This is the class definition: </p>
  
  <pre><code>namespace BigNum {
  
      class BigInt {
      public:
          BigInt();
          BigInt(int64_t n);
          BigInt(std::string s);
  
          friend std::istream&amp; operator&gt;&gt; (std::istream&amp; in, BigInt&amp; n);
          friend std::ostream&amp; operator&lt;&lt; (std::ostream&amp; out, BigInt n);
  
          friend bool operator&lt; (const BigInt&amp; a, const BigInt&amp; b);
          friend bool operator&gt; (const BigInt&amp; a, const BigInt&amp; b);
          friend bool operator== (const BigInt&amp; a, const BigInt&amp; b);
          friend bool operator!= (const BigInt&amp; a, const BigInt&amp; b);
          friend bool operator&lt;= (const BigInt&amp; a, const BigInt&amp; b);
          friend bool operator&gt;= (const BigInt&amp; a, const BigInt&amp; b);
  
          operator bool();
          explicit operator int();
          friend void swap (BigInt&amp; a, BigInt&amp; b);
  
          friend BigInt operator+ (BigInt a, BigInt b);
  
      private:
          std::vector&lt;int&gt; digits; 
          std::size_t number_of_digits;
      };
  }
  </code></pre>
  
  <p>And these are the methods used:</p>
  
  <pre><code>BigNum::BigInt::BigInt(int64_t n) {
  
      if (n == 0) {
          BigInt();
          return;
      }
  
      // The number is stored in reverse
      for (; n; n /= 10)
          digits.emplace_back(n % 10);
  
      number_of_digits = digits.size();
  }
  
  std::ostream&amp; BigNum::operator&lt;&lt; (std::ostream&amp; out, BigNum::BigInt n) {
  
      for (auto it = n.digits.rbegin(); it != n.digits.rend(); ++it)
          out &lt;&lt; *it;
  
      return out;
  }
  
  void BigNum::swap (BigNum::BigInt&amp; a, BigNum::BigInt&amp; b) {
  
      BigNum::BigInt temp(a);
      a = b;
      b = temp;
  }
  
  BigNum::BigInt BigNum::operator+ (BigNum::BigInt a, BigNum::BigInt b) {
  
      if (a &lt; b)
          BigNum::swap(a, b);
  
      BigNum::BigInt result(a);
  
      int transport = 0;
      for (std::size_t i = 0; i &lt; b.number_of_digits; ++i) {
  
          result.digits[i] += b.digits[i] + transport;
          transport         = result.digits[i] / 10;
          result.digits[i] %= 10;
      }
  
      if (transport)
          result.digits.emplace_back(transport);
  
      ++result.number_of_digits;
  
      return result;
  }
  </code></pre>
  
  <p>If I write something like:</p>
  
  <pre><code>BigNum::BigInt a = 2;
  BigNum::BigInt b = a + 1;
  </code></pre>
  
  <p>I get that error. I've made the int typecast explicit, but it didn't help out. I don't want to also make the constructor explicit, as that will mean that I'll no longer be able to assign an int to a BigInt (like I did in the previous example).
  How can I fix this?</p>