title: Conversion from lambda to non-scalar type requested
body: <p>I created this class so I could have a value of any type which is either fixed or recalculated everytime it's used:</p>
  <pre><code>template&lt;typename T&gt;
  class Value {
      private:
      bool fixed;
      union {
          T value;
          std::function&lt;T()&gt; get;
      };
      public:
      Value(const T&amp; value) : fixed(true), value(value) {}
      Value(const std::function&lt;T()&gt;&amp; get) : fixed(false), get(get) {}
      Value(const T *pointer) : Value([pointer]() { return *pointer; }) {}
      ~Value() {}
      operator T() { return fixed ? value : get(); }
  };
  </code></pre>
  <p>All the following expressions seem to work fine:</p>
  <pre><code>Value&lt;double&gt; a = 2.2;
  double b = 1.;
  double c = a;
  Value&lt;double&gt; d = &amp;b;
  Value&lt;int&gt; e = Value&lt;int&gt;([]() { return 1.; });
  </code></pre>
  <p>But when I try to do:</p>
  <pre><code>Value&lt;double&gt; f = []() { return 1.; };
  </code></pre>
  <p>a compilation error is triggered:</p>
  <pre><code>error: conversion from 'main()::&lt;lambda()&gt;' to non-scalar type 'Value&lt;double&gt;' requested
  </code></pre>
  <p>You can try this example <a href="https://godbolt.org/z/bf8srh" rel="nofollow noreferrer">here</a>.</p>
  <p>Why does assigning work for <code>T</code> and not <code>std::function&lt;T()&gt;</code> and how can I make it so it does?</p>
  <p>Note: I'm aware of <a href="https://stackoverflow.com/a/51795627/5308892">this answer</a> but I didn't become clear to me how to fix the issue without having to explicitly call the constructor like I did for <code>Value&lt;double&gt; e</code>.</p>