Compiler complains make_shared() expects l-value
<p>I have a simple class.  One of its constructors takes two <code>int</code> values as arguments:</p>

<p>simple_class.h</p>

<pre><code>class SimpleClass {
   private:
      int d_ii;
      int d_jj;
   public:
      SimpleClass() : d_ii(40), d_jj(10) {}
      SimpleClass( const int ii, const int jj ) : d_ii(ii), d_jj(jj) {}
};
</code></pre>

<p>test.t.cpp</p>

<pre><code>//----------------------------------------------------------------//
//
//  Test Program
#include &lt;memory&gt;
#include &lt;simple_class.h&gt;

int main ( int argc, char * argv[] )
{
   SimpleClass sc1;
   SimpleClass sc2( 10, 20 );

   std::shared_ptr&lt;SimpleClass&gt; spSc1( new SimpleClass(10,12) );

   int ii = 10;
   int jj = 16;
   std::shared_ptr&lt;SimpleClass&gt; spSc2 = std::make_shared&lt;SimpleClass&gt; ( ii, jj );

   std::shared_ptr&lt;SimpleClass&gt; spSc3 = std::make_shared&lt;SimpleClass&gt; ( 10, 16 );

   return 0;
}
</code></pre>

<p>Running on a macbook.  Here is my compile statement:</p>

<blockquote>
  <p>gcc -o test -I. test.t.cpp -lstdc++</p>
</blockquote>

<p>But it produces this error:</p>

<pre><code>test.t.cpp:18:41: error: no matching function for call to 'make_shared'
 std::shared_ptr&lt;SimpleClass&gt; spSc3 = std::make_shared&lt;SimpleClass&gt; ( 10, 16 );
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4708:1: note:
      candidate function [with _Tp = SimpleClass, _A0 = int, _A1 = int] not viable: expects an l-value for 1st
      argument
make_shared(_A0&amp; __a0, _A1&amp; __a1)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4692:1: note:
      candidate function template not viable: requires 0 arguments, but 2 were provided
make_shared()
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4700:1: note:
      candidate function template not viable: requires single argument '__a0', but 2 arguments were provided
make_shared(_A0&amp; __a0)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4716:1: note:
      candidate function template not viable: requires 3 arguments, but 2 were provided
make_shared(_A0&amp; __a0, _A1&amp; __a1, _A2&amp; __a2)
^
1 error generated.
</code></pre>

<p>So my question is, why doesn't this usage of <code>make_shared()</code> work?</p>

<pre><code>std::shared_ptr&lt;SimpleClass&gt; spSc2 = std::make_shared&lt;SimpleClass&gt;( 10, 16 );
</code></pre>

<p>Notice that the version with the l-values passed <em>does</em> compile:</p>

<pre><code>   int ii = 10;
   int jj = 16;
   std::shared_ptr&lt;SimpleClass&gt; spSc2 = std::make_shared&lt;SimpleClass&gt; ( ii, jj );
</code></pre>

<p>Can anyone explain why this is?</p>

<p>My constructor declares the arguments as <code>const</code> (although that should not be necessary).  And the <a href="http://www.cplusplus.com/reference/memory/make_shared/" rel="nofollow noreferrer">examples given here</a> pass constants to <code>make_shared()</code>.</p>