Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8930061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:48:01+00:00 2026-06-15T08:48:01+00:00

I used std::variate_generator in the following way in a VS2010 project: #include <random> …

  • 0

I used std::variate_generator in the following way in a VS2010 project:

#include <random>
...
using std::variate_generator;
using std::mt19937;
using std::uniform_real_distribution;

typedef mt19937                                     Engine;
typedef uniform_real_distribution<float>            Distribution;
typedef variate_generator< Engine, Distribution >   Generator;  

Generator r( Engine((DWORD)time(NULL)), Distribution(0.0f, 1.0f) ); 

// from now, calling float rnd = r() gave me a random number between 0.0f and 1.0f in rnd.

I’ve now put this code into a VS2012 solution and the error message I’m getting is that std::variate_generator is not a member of std.

Has std::variate_generator moved or been removed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:48:02+00:00Added an answer on June 15, 2026 at 8:48 am

    variate_generators aren’t used in the final standard version of <random>. variate_generator was part of tr1 but never made it into the standard, so I’m a bit surprised std::variate_generator worked in VS2010 (as opposed to std::tr1::variate_genrator). I believe it still exists in VS2012’s tr1 namespace though.

    You can do the following instead:

    #include <random>
    #include <functional> // for std::bind
    ...
    using std::mt19937;
    using std::uniform_real_distribution;
    
    typedef mt19937                                     Engine;
    typedef uniform_real_distribution<float>            Distribution;
    
    auto r = std::bind(Distribution(0.0f, 1.0f), Engine((DWORD)time(NULL)));
    
    // from now, calling float rnd = r() gave me a random number between 0.0f and 1.0f in rnd.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've used #include<stdlib> #include<time> using namespace std; srand((unsigned)time(0)); int n=(rand()>>8)%4; but what other random
I'm having a hard time with current project. In previous versions I used std::vectors
Consider the following code. I want to specialize std::hash<> used in a Map ,
std::swap() is used by many std containers (such as std::list and std::vector ) during
I have a class with a std::map used as a container. I want to
std::vector<std::pair<std::string > > can be used to store a list of a pair of
What is the basic usage of std::tr1::aligned_storage ? Can it be used as auto
I have seen the following definition throughout legacy code: std::vector<boost::shared_ptr<ClassNameAAA>> vecClass; I am able
I have some questions on using std::map : Is using an enum as the
When using the std::map with types that use trivial, non-throwing, copy constructors, a compiler

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.