Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #459

Re: Random number engine adaptor requirements [rand.req.adapt]

From MiloRambaldi<james.hirschorn@gmail.com>
Newsgroups comp.std.c++
Subject Re: Random number engine adaptor requirements [rand.req.adapt]
Date 2012-03-23 17:10 -0700
Organization http://groups.google.com
Message-ID <15191105.1210.1332508808424.JavaMail.geo-discussion-forums@vbut24> (permalink)
References <5521955.2673.1332349807497.JavaMail.geo-discussion-forums@vbue17> <jkdale$17a$1@dont-email.me>

Show all headers | View raw


Hi Daniel,

Sorry but I was not asking about the right section. 26.5.1.5 is about types, whereas I was asking about engine adapter templates.

My corrected question is essentially the same:

In section 26.5.4 Random number engine adaptor class templates [rand.adapt], nothing is said about whether the random engine adapter template must accept, as a type template parameter, *all* random number engine types as in section 26.5.1.4. If a class template will only compile for a subset of all of the random number engine types, can it still satisfy the requirements of 26.5.4?

On Thursday, March 22, 2012 2:23:45 PM UTC-4, Daniel Krügler wrote:
>
>  In my opinion you are talking about two issues:
>
>  1) The most simple one is your last question: The answer is trivial:
>  Every requirement set can be refined to an arbitrary degree of
>  constraints. Given that fundamental property of refinements of concepts
>  there is no point that you can define your own random number engine
>  adaptor that accepts only a restricted set of engines (and the
>  restrictions can be defined by your-self).

I think I've now clarified that (1) is not an issue?
>
>  2) Nonetheless I think that you are asking an interesting question in
>  regard to what the library specification describes. It is a fact that
>  all specialized library-defined engine adaptors do refer to evaluating
>  the expression e() given its engine(s) e in some way. This is to be
>  expected given the "interface" of general random number engines. From
>  the perspective of the standard, there does not exist any engine concept
>  which provides another way of reading the generated values of it's state
>  except from a function call expression without parameters. ...

Yes, this is the whole point: I am assuming that an engine could provide some other way of reading generated values, in addition to those required by the standard, and still satisfy the requirements of 26.5.1.4 (yes?)

I will describe some specifics on the engine adapter template that led to my question. I have my own concept of a "reversible random number engine", refining 26.5.1.4. In addition to the requirements of a random number engine, a reversible random number engine provides a method reverse() which generates random numbers in reverse order of operator()(). Then I have an adapter template called reverse_adapter:

template<typename Engine, ...>  class reverse_adapter { ... };

In general it will only compile if Engine is a reversible random number engine (i.e. has a reverse() method). (It should be obvious what the adapter does.)

My question is whether reverse_adapter can satisfy the requirements of the standard, since it will not accept all Engine types? My interpretation of the standard is yes, since there is no explicit requirement to accept all Engine types. However, I know others who have interpreted this section of the standard differently.


-- 
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Random number engine adaptor requirements [rand.req.adapt] MiloRambaldi<james.hirschorn@gmail.com> - 2012-03-21 11:35 -0700
  Re: Random number engine adaptor requirements [rand.req.adapt] Daniel Krügler<daniel.kruegler@googlemail.com> - 2012-03-22 11:23 -0700
    Re: Random number engine adaptor requirements [rand.req.adapt] MiloRambaldi<james.hirschorn@gmail.com> - 2012-03-23 17:10 -0700
      Re: Random number engine adaptor requirements [rand.req.adapt] Daniel Krügler <daniel.kruegler@googlemail.com> - 2012-03-24 19:26 -0700
        Re: Random number engine adaptor requirements [rand.req.adapt] MiloRambaldi<james.hirschorn@gmail.com> - 2012-04-02 15:16 -0700
          Re: Random number engine adaptor requirements [rand.req.adapt] Daniel Krügler <daniel.kruegler@googlemail.com> - 2012-04-03 23:20 -0700

csiph-web