
Hi, Is there any plans to split call_traits? I really need only reference type trait. Shouldn't it be part of type traits lib? Is there an alternative already in there? Thanks, Gennadiy

Gennadiy Rozental wrote:
Hi,
Is there any plans to split call_traits? I really need only reference type trait. Shouldn't it be part of type traits lib? Is there an alternative already in there?
How about: #include <boost/type_traits/add_reference.hpp> boost::add_reference<T>::type ? João

"John Maddock" <john@johnmaddock.co.uk> wrote in message news:01a501c53451$6288b950$2f3f0252@fuji...
Is there any plans to split call_traits? I really need only reference type trait. Shouldn't it be part of type traits lib? Is there an alternative already in there?
Yes, add_reference does the same thing, we should really add an add_const_reference as well.
John.
Sorry, I actually need param_type. Reference indeed is just add_[const_]reference. Any idea in this direction? Gennadiy

Sorry, I actually need param_type. Reference indeed is just add_[const_]reference.
Any idea in this direction?
You mean: template <class T> struct add_const_reference { private: typedef typename remove_reference<T>::type nref_t; typedef typename add_const<nref_t>::type ct; public: typedef typename add_reference<ct>::type type; }; ??? John.

"John Maddock" <john@johnmaddock.co.uk> wrote in message news:026501c53480$8ce0fb20$2f3f0252@fuji...
Sorry, I actually need param_type. Reference indeed is just add_[const_]reference.
Any idea in this direction?
You mean:
template <class T> struct add_const_reference
No I mean any idea about template<typename T> param_type { .... }; Shouldn't we deprecate call traits if(once) we have corresponding traits in Traits_lib. Gennadiy.

No I mean any idea about
template<typename T> param_type { .... };
Shouldn't we deprecate call traits if(once) we have corresponding traits in Traits_lib.
Or possibly deprecate param_type ;-) On most modern machines the difference between passing small types by reference and by value is negligible, the main use is to prevent aliasing (similar to C99's restrict keyword): void f(T& a, const T& b) { while(condition) { // do something with b here } } In a situation like this b gets reloaded from memory with each pass through the loop (because it may be aliased by a), whereas this does not occur with pass-by-value, and even then you may be better off with just: void f(T& a, const T& b) { T t(b); while(condition) { // do something with t here } } or: void f(T& a, const T& b) { register typename some_heuistic<T>::type t(b); while(condition) { // do something with t here } } Where some_heuistic is specific to your algorithm, but is similar to param_type. If you still want param_type, then given that 90% plus of the code in call_traits.hpp is there to implement param_type, why not just use call_traits if that's what you want? John.

"John Maddock" wrote:
Or possibly deprecate param_type ;-)
On most modern machines the difference between passing small types by reference and by value is negligible, the main use is to prevent aliasing (similar to C99's restrict keyword):
Similar feature was (cca year ago) added into STLport. Measurements had shown several % speedup for vector<int>::push_back(). Implementors of STL count every cycle. /Pavel
participants (4)
-
Gennadiy Rozental
-
Joao Abecasis
-
John Maddock
-
Pavel Vozenilek