title: Why does this use of boost::none fail to compile with nvcc?
body: <p>I'm trying to compile the following code:</p>
  
  <pre><code>#include &lt;boost/optional.hpp&gt;
  void foo(boost::optional&lt;unsigned&gt; x = boost::none);
  </code></pre>
  
  <p>placed in the file <code>a.cu</code>, with the CUDA compiler, using the following command line:</p>
  
  <pre><code>nvcc a.cu -c --std=c++11 -I/opt/boost/include
  </code></pre>
  
  <p>but I get a bunch of errors:</p>
  
  <pre><code>a.cu:2:53: error: conversion from ‘const boost::none_t(boost::none_t::init_tag (*)())’ to ‘boost::optional&lt;unsigned int&gt;’ is ambiguous
   void foo(boost::optional&lt;unsigned&gt; x = boost::none);
                                                       ^
  /opt/boost/include/boost/optional/optional.hpp:805:1: note: candidate: boost::optional&lt;T&gt;::optional(boost::optional&lt;T&gt;::rval_reference_type) [with T = unsigned int; boost::optional&lt;T&gt;::rval_reference_type = unsigned int&amp;&amp;] &lt;near match&gt;
       optional ( rval_reference_type val ) : base( boost::forward&lt;T&gt;(val) )
   ^   ~~~~
  /opt/boost/include/boost/optional/optional.hpp:805:1: note:   conversion of argument 1 would be ill-formed:
  a.cu:2:53: error: invalid conversion from ‘const boost::none_t (*)(boost::none_t::init_tag (*)())’ to ‘unsigned int’ [-fpermissive]
   void foo(boost::optional&lt;unsigned&gt; x = boost::none);
                                                       ^
  /opt/boost/include/boost/optional/optional.hpp:800:1: note: candidate: boost::optional&lt;T&gt;::optional(boost::optional&lt;T&gt;::argument_type) [with T = unsigned int; boost::optional&lt;T&gt;::argument_type = const unsigned int&amp;] &lt;near match&gt;
       optional ( argument_type val ) : base(val) {}
   ^   ~~~~
  /opt/boost/include/boost/optional/optional.hpp:800:1: note:   conversion of argument 1 would be ill-formed:
  a.cu:2:53: error: invalid conversion from ‘const boost::none_t (*)(boost::none_t::init_tag (*)())’ to ‘unsigned int’ [-fpermissive]
   void foo(boost::optional&lt;unsigned&gt; x = boost::none);
  </code></pre>
  
  <p>Why does this happen, and can I circumvent the problem while still actually using boost::optional in (host-side) code compiled with nvcc?</p>
  
  <p>Additional information:</p>
  
  <ul>
  <li>The code compiles fine with g++ 6.3.0 (my distribution's compiler). </li>
  <li>This code (or rather, similar code) <em>used</em> to compile and work on an earlier Linux distribution I was using, where the compiler was g++ 5.4.x .</li>
  <li>I've tried this with Boost versions 1.65.1 and 1.69.0 .</li>
  <li>I've tried this with CUDA versions 9.2.88 and 10.0.130 . </li>
  </ul>