title: Can you explain this overload resolution behavior?
body: <p>This code snippet will not compile using VS2013 or ICC 16:</p>
  
  <pre><code>class C2;
  
  class C1
  {
  public:
    float x, y;
  
    template&lt;typename T&gt;
    C1 (T x, T y) : x(static_cast&lt;float&gt;(x)), y(static_cast&lt;float&gt;(y)) {};
    C1 (const C2 &amp;a, int i) : x(0), y(0) {};
  };
  
  void main()
  {
      C1 p(1.5, 2);
  }
  </code></pre>
  
  <p>because no instance of <code>C1</code> constructor matches the argument list <code>(double, int)</code>, but when I replace <code>C2</code> with <code>PolyLine</code> it does compile and <code>1.5</code> is somehow cast to <code>PolyLine</code>. I test it inside a large project with many dependencies, so I can fit only a fragment of the header here:</p>
  
  <pre><code>class PolyLine 
  {
  protected:
      enum {INIT_LENGTH = 16};
  
  public:
    typedef float (PolyLine::*Fit)(Point2D&amp;, Point2D&amp;, const int, const int, const float) const;
  
      vector&lt;float&gt; x;  ///&lt; Vector with X axis coordinates of polyline nodes.
      vector&lt;float&gt; y;  ///&lt; Vector with Y axis coordinates of polyline nodes.
  
      PolyLine (int initLength = INIT_LENGTH);
      PolyLine (const PolyLine &amp;poly, int firstNode = -1, int lastNode = -1);
      PolyLine (const PolyLine &amp;poly, const float MAX_ERROR, vector&lt;int&gt; *nodeMap = 0);
      PolyLine (ifstream* input);
    PolyLine (string fileName)  {loadTxt (fileName);};
      PolyLine (const float SAMPLING_RESOLUTION, PolyLine &amp;poly);
      PolyLine (const vector&lt;float&gt; &amp;v, float step = 1.0);
      PolyLine (const vector&lt;int&gt; &amp;v, float step = 1.0);
      PolyLine (const deque&lt;float&gt; &amp;x, const deque&lt;float&gt; &amp;y) : x(x.begin(), x.end()), y(y.begin(), y.end()) {};
  </code></pre>
  
  <p>What are the circumstances when <code>PolyLine</code> can be cast to <code>double</code>? </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>After reading the first answers, I reduced this example to:</p>
  
  <pre><code>class PolyLine 
  {
  public:
    PolyLine(int i = 7) {};
  };
  </code></pre>
  
  <p>Marking <code>PolyLine</code> constructor <code>explicit</code> produces desired effect. </p>