|
Ublas : |
From: Andrew Rieck (arieck_at_[hidden])
Date: 2005-07-11 20:01:43
See below.
ublas-bounces_at_[hidden] wrote on 11/07/2005 10:49:20 PM:
> You should be a bit careful with result_of. It does not utilize SFINAE,
so
> if you write a forwarding template operator such as
>
> template <typename T, typename U>
> typename result_of<plus(T,U)>::type
> operator+(T const& x, U const& y)
> {
> return plus()(x,y);
> }
>
> it will match ALL combinations of T,U but give a compile-time error if
> result_of<plus<T,U> > cannot be determined. So the above usage of
> result_of turns out to be useless. Result_of does not do any typeof
magic
> either, it can determine the result_of only for function types (where
the
> return type is part of the type anyway), and function objects for which
a
> nested type f::result<X>::type.is defined. So I am not sure that it can
> replace the logic of promote_traits anyway.
Not utilizing SFINAE(substitution failure is not an error) is indeed an
issue if the above operator (or mechanisim in general) is fully exposed to
the general user as Ian has pointed out above. However, this negative is
mitigated by two positives. Firstly, #include
<boost/utility/result_of.hpp> is a library that people can easily
understand and so more people will be able to understand and contribute to
ublas. Secondly, if it is used internally where classes and types are
defined for the appropriate "scalars", it does provide valuable
compile-time errors because of the fact that it does not utilize SFINAE.
Kind regards,
Andrew
Please consider our environment before printing this email.
WARNING - This email and any attachments may be confidential. If received in error, please delete and inform us by return email. Because emails and attachments may be interfered with, may contain computer viruses or other defects and may not be successfully replicated on other systems, you must be cautious. Westpac cannot guarantee that what you receive is what we sent. If you have any doubts about the authenticity of an email by Westpac, please contact us immediately.
It is also important to check for viruses and defects before opening or using attachments. Westpac's liability is limited to resupplying any affected attachments.
This email and its attachments are not intended to constitute any form of financial advice or recommendation of, or an offer to buy or offer to sell, any security or other financial product. We recommend that you seek your own independent legal or financial advice before proceeding with any investment decision.
Westpac Institutional Bank is a division of Westpac Banking Corporation, a company registered in New South Wales in Australia under the Corporations Act 2001 (Cth). Westpac is authorised and regulated in the United Kingdom by the Financial Services Authority and is registered at Cardiff in the United Kingdom as Branch No. BR 106. Westpac operates in the United States of America as a federally chartered branch, regulated by the Office of the Comptroller of the Currency.
Westpac Banking Corporation ABN 33 007 457 141.