Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2000-12-04 10:59:41


Hoping to have the 'typeof' operator in the next revision of the standard,
but being forced to write my code today, I'm inclined to a thought that
boost should provide (temporary ;) some sort of 'standard' library for
dealing with the issues related to the types' deduction problem. There are a
lot of libraries out there that already do this kind of stuff internally -
Blitz++ and the Lambda Library are probably the most well-known - but,
unfortunately, in both cases the Blitz++ 'promote_trait' or LL
'return_type' are (for now) too coupled to other parts of the libraries and,
IMO, their implementations of trait classes in some places cut off the
corners ;).

So, having knowledge that the LL are currently being splitted into
independent components anyway :), it might be a good time to start a
discussion about the issue. I've uploaded to the vault my quick try to
implement a more generic 'types_promotion_traits' "library" (which I'm
planning to use in my geometry2d stuff); given it and the LL
'return_type_traits.hpp' header, I think we already have a lot of things to
discuss ;)

Any comments are welcome.

--Aleksey

P.S. a quick demonstration of how types_promotion_traits<> template works;
nothing new - just old boring 'typeof' :)

template<class T>
struct my {
  my(T const& v) : value(v) {}
  T value;
};

template<class T1, class T2>
my< boost::types_promotion_traits<T1, T2>::type >
operator+( my<T1> const& m1, my<T2> const& m2 ) {
  return m1.value + m2.value;
}

int main() {
  assert((my<int>(10) + my<double>(1.3)).value == 11.3);
  return 0;
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk