Opened 21 years ago

Closed 21 years ago

#926 closed Bugs (Rejected)

Problem with seed interface

Reported by: nobody Owned by: jmaurer
Milestone: Component: random
Version: None Severity:
Keywords: Cc:

Description

For a random number generator x, you can call

x.seed(s)

where s is either an integer of the appropriate type,
or a generator.
This overloading causes a problem, because if s an
integer type
other than the DataType for x, the compiler matches it
with the overload that takes a generator argument,
producing a very puzzling
compiler error.

Change History (1)

comment:1 by jmaurer, 21 years ago

Status: assignedclosed
Logged In: YES 
user_id=53943

This is indeed a bit surprising, but it only happens
if "s" (in your above example) is an lvalue.
Also, you can always cast the argument to the appropriate
type first, e.g. by static_cast<RNG::result_type>(s)
And you do get an error message if the wrong seed function
is called.  The documentation could be a bit more verbose
about that, though (fixed).

Note: See TracTickets for help on using tickets.