compile time type check

E

er

Hi All,

how can i enforce the requirement below ?

template<class RANDOM>//template member function
double A<RANDOM>::eek:perator()(RANDOM& u){
/* requirement: RANDOM::result_type is double */

/* body of the function */
};
 
A

Alf P. Steinbach

* er:
how can i enforce the requirement below ?

template<class RANDOM>//template member function
double A<RANDOM>::eek:perator()(RANDOM& u){
/* requirement: RANDOM::result_type is double */

/* body of the function */
};

The Boost library provides facilities for compile time assertions and
compile time checking of whether two types are the same. Compile time
assertions will become part of the language in C++0x, but with slightly
different syntax than the Boost macro. There is however a good chance
that it would be better to rethink the design rather than enforce.

Btw., don't use all uppercase for non-macro names.

Reserve all uppercase for macro names, to reduce possibility of name
collisions.


Cheers, & hth.,

- Alf
 
E

er

* er:






The Boost library provides facilities for compile time assertions and
compile time checking of whether two types are the same. Compile time

Do you mean BOOST_STATIC_ASSERT? If so, specifically how do I define
the predicate in my case?
assertions will become part of the language in C++0x, but with slightly
different syntax than the Boost macro. There is however a good chance
that it would be better to rethink the design rather than enforce.

Basically in my example A<Random>::eek:perator()(Random&) returns a
random value derived from Random(), that's all. Any suggestion on how
to rethink the design then?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top