Naming integer, real and either template types

I am writing template math functions. Some can take integral types (only) Some can take real (both built-in floating-point - float, double.. AND User Defined real types) And some can take either integral OR real. Real : Floating-point types Integer : Integral types Arithmetic : Either Integral OR Floating-point types Arithmetic is a bit long - other ideas? So to write a function something like template <class RealType> RealType students_t(ArithmeticType degrees_of_freedom, RealType t) { ... } Using just T is not an option because there are three (at least) possibles. What names should I use for the types? RealType, real_type, RealT, or RT, or ??? IntType, int_type, IntT, IT, or ??? ArithmeticType, arithmetic_type, ArithType, arith_type, AT ??? Suggestions for names please. Rationales? Prior art? Precedents? Standards? Thanks Paul --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com

Hi Paul, "Paul A Bristow" <pbristow@hetp.u-net.com> wrote in message news:E1FvDk8-0005y8-PO@he303war.uk.vianw.net...
I am writing template math functions.
Some can take integral types (only)
Some can take real (both built-in floating-point - float, double.. AND User Defined real types)
And some can take either integral OR real.
Real : Floating-point types Integer : Integral types Arithmetic : Either Integral OR Floating-point types
Arithmetic is a bit long - other ideas?
So to write a function something like
template <class RealType> RealType students_t(ArithmeticType degrees_of_freedom, RealType t) { ... }
Using just T is not an option because there are three (at least) possibles.
What names should I use for the types?
I think they are Concepts rather than types FWIW. template <class ArithmeticType ,class RealType> RealType students_t(ArithmeticType degrees_of_freedom, RealType t) { ... } I assume you meant that above?
RealType, real_type, RealT, or RT, or ???
IntType, int_type, IntT, IT, or ???
ArithmeticType, arithmetic_type, ArithType, arith_type, AT ???
Suggestions for names please. Rationales? Prior art? Precedents? Standards?
Thanks
Sounds to me like these Concepts and their requirements need to be written and put somewhere in the Boost Docs. . I would be happy to help, but given my recent form regarding Concepts, I'm probably not the best person to ask! ;-). Anyway I think they are needed and very useful. Maybe you should start here: http://www.boost.org/libs/concept_check/reference.htm#basic-concepts Maybe you could also use type_traits as a basis for names. regards Andy Little

"Andy Little" wrote
"Paul A Bristow" wrte
I am writing template math functions.
Some can take integral types (only)
Some can take real (both built-in floating-point - float, double.. AND User Defined real types)
And some can take either integral OR real.
Real : Floating-point types Integer : Integral types Arithmetic : Either Integral OR Floating-point types
Arithmetic is a bit long - other ideas?
So to write a function something like
template <class RealType> RealType students_t(ArithmeticType degrees_of_freedom, RealType t) { ... }
Using just T is not an option because there are three (at least) possibles.
What names should I use for the types?
I think they are Concepts rather than types FWIW.
template <class ArithmeticType ,class RealType> RealType students_t(ArithmeticType degrees_of_freedom, RealType t) { ... }
I assume you meant that above?
RealType, real_type, RealT, or RT, or ???
IntType, int_type, IntT, IT, or ???
ArithmeticType, arithmetic_type, ArithType, arith_type, AT ???
Suggestions for names please. Rationales? Prior art? Precedents? Standards?
Thanks
Sounds to me like these Concepts and their requirements need to be written and put somewhere in the Boost Docs. . I would be happy to help, but given my recent form regarding Concepts, I'm probably not the best person to ask! ;-). Anyway I think they are needed and very useful. Maybe you should start here:
http://www.boost.org/libs/concept_check/reference.htm#basic-concepts
Maybe you could also use type_traits as a basis for names.
I am wondering if you had any more thoughts regarding these Concepts? They would be very useful for the Quan http://sourceforge.net/projects/quan documentation. and for general use. Has anyone any thoughts on this, or better, are these Concepts defined somewhere? regards Andy Little

Some can take integral types (only)
Some can take real (both built-in floating-point - float, double.. AND User Defined real types)
And some can take either integral OR real.
Real : Floating-point types Integer : Integral types Arithmetic : Either Integral OR Floating-point types
Arithmetic is a bit long - other ideas?
How about Number? It is used in some languages (e.g. javascript) that don't have both float and int. Darren
participants (3)
-
Andy Little
-
Darren Cook
-
Paul A Bristow