title: Custom UniformRandomBitGenerator fails to compile
body: <p>I am trying to create a wrapper around the random number generation sources defined in C++  header that return uint_fast32_t, such that one base class can store a pointer to any RNG (std::mt19937, std::default_random, etc).  This is for the purpose of storing random number generation sources as class members without having to make the class a template class.  The solution I came up with: I defined an abstract base class RNGSource that implements the C++ <a href="http://en.cppreference.com/w/cpp/concept/UniformRandomBitGenerator" rel="nofollow noreferrer">UniformRandomBitGenerator</a> standard.  Then, I defined a template class RNGSourceWrap that implements RNGSource, takes some C++ rng source as a parameter, and implements the RNGSource functions to forward calls to the underlying C++ rng stored.  The code is as follows:</p>
  
  <pre><code>#ifndef RANDOM_H
  #define RANDOM_H
  #include &lt;cstdint&gt;
  
  
  class RNGSource
  {
      public: 
          virtual ~RNGSource() = default;
          typedef uint_fast32_t result_type;
          virtual result_type operator() () = 0;
          virtual result_type min() const = 0;
          virtual result_type max() const = 0;
  };
  
  
  template &lt;class Generator&gt;
  class RNGSourceWrap : public RNGSource
  {
      public:
          RNGSourceWrap(Generator* rng);
  
          virtual result_type operator() () override;
          virtual result_type min() const override;
          virtual result_type max() const override;
          Generator* rng() const;
  
      private:
          Generator* rngVal;
  };
  
  template &lt;class Generator&gt;
  RNGSourceWrap&lt;Generator&gt;::RNGSourceWrap(Generator* rng)
      : rngVal(rng) { }
  
  template &lt;class Generator&gt;
  typename RNGSourceWrap&lt;Generator&gt;::result_type 
  RNGSourceWrap&lt;Generator&gt;::operator() () { return rngVal-&gt;operator() (); }
  
  template &lt;class Generator&gt;
  typename RNGSourceWrap&lt;Generator&gt;::result_type 
  RNGSourceWrap&lt;Generator&gt;::min() const { return rngVal-&gt;min(); }
  
  template &lt;class Generator&gt;
  typename RNGSourceWrap&lt;Generator&gt;::result_type 
  RNGSourceWrap&lt;Generator&gt;::max() const { return rngVal-&gt;max(); }
  
  template &lt;class Generator&gt;
  Generator* RNGSourceWrap&lt;Generator&gt;::rng() const { return rngVal; }
  #endif // RANDOM_H
  </code></pre>
  
  <p>I wrote a small main to test funtionality:</p>
  
  <pre><code>#include "random.h"
  #include &lt;random&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      std::mt19937 rng;
  
      RNGSource* rngWrap = new RNGSourceWrap&lt;std::mt19937&gt;(&amp;rng);
      std::uniform_int_distribution&lt;int&gt; distro(1, 6);
      int myInt = distro(*rngWrap);
  
      std::cout &lt;&lt; myInt &lt;&lt; std::endl;
  
      delete rngWrap;
  
      return 0;
  }
  </code></pre>
  
  <p>This code compiles and runs with no warnings or errors when compiled with Linux g++ and MinGW using c++ 14 standard.  However, it generates errors when compiled with MSVC (using Visual Studio 2017 Community):</p>
  
  <pre><code>1&gt;------ Build started: Project: RNGTestApp, Configuration: Debug Win32 ------
  1&gt;main.cpp
  1&gt;c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\xutility(3479): error C2352: 'RNGSource::max': illegal call of non-static member function
  1&gt;[PATH REMOVED]\visual studio 2017\projects\rngtestapp\random.h(14): note: see declaration of 'RNGSource::max'
  1&gt;c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\xutility(3476): note: while compiling class template member function 'std::_Rng_from_urng&lt;unsigned int,_Engine&gt;::_Rng_from_urng(_Urng &amp;)'
  1&gt;        with
  1&gt;        [
  1&gt;            _Engine=RNGSource,
  1&gt;            _Urng=RNGSource
  1&gt;        ]
  1&gt;c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\random(2353): note: see reference to function template instantiation 'std::_Rng_from_urng&lt;unsigned int,_Engine&gt;::_Rng_from_urng(_Urng &amp;)' being compiled
  1&gt;        with
  1&gt;        [
  1&gt;            _Engine=RNGSource,
  1&gt;            _Urng=RNGSource
  1&gt;        ]
  1&gt;c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\random(2353): note: see reference to class template instantiation 'std::_Rng_from_urng&lt;unsigned int,_Engine&gt;' being compiled
  1&gt;        with
  1&gt;        [
  1&gt;            _Engine=RNGSource
  1&gt;        ]
  1&gt;c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\random(2312): note: see reference to function template instantiation 'int std::uniform_int&lt;_Ty&gt;::_Eval&lt;_Engine&gt;(_Engine &amp;,_Ty,_Ty) const' being compiled
  1&gt;        with
  1&gt;        [
  1&gt;            _Ty=int,
  1&gt;            _Engine=RNGSource
  1&gt;        ]
  1&gt;c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\random(2312): note: see reference to function template instantiation 'int std::uniform_int&lt;_Ty&gt;::_Eval&lt;_Engine&gt;(_Engine &amp;,_Ty,_Ty) const' being compiled
  1&gt;        with
  1&gt;        [
  1&gt;            _Ty=int,
  1&gt;            _Engine=RNGSource
  1&gt;        ]
  1&gt;[PATH REMOVED]\visual studio 2017\projects\rngtestapp\main.cpp(11): note: see reference to function template instantiation 'int std::uniform_int&lt;_Ty&gt;::operator ()&lt;RNGSource&gt;(_Engine &amp;) const' being compiled
  1&gt;        with
  1&gt;        [
  1&gt;            _Ty=int,
  1&gt;            _Engine=RNGSource
  1&gt;        ]
  1&gt;[PATH REMOVED]\visual studio 2017\projects\rngtestapp\main.cpp(11): note: see reference to function template instantiation 'int std::uniform_int&lt;_Ty&gt;::operator ()&lt;RNGSource&gt;(_Engine &amp;) const' being compiled
  1&gt;        with
  1&gt;        [
  1&gt;            _Ty=int,
  1&gt;            _Engine=RNGSource
  1&gt;        ]
  1&gt;c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.11.25503\include\xutility(3479): error C2352: 'RNGSource::min': illegal call of non-static member function
  1&gt;[PATH REMOVED]\visual studio 2017\projects\rngtestapp\random.h(13): note: see declaration of 'RNGSource::min'
  1&gt;Done building project "RNGTestApp.vcxproj" -- FAILED.
  </code></pre>
  
  <p>Given that this does compile using Linux g++ and MinGW, and appears to qualify as implementing the UniformRandomBitGenerator standard, is this a compiler bug?  </p>