Created on 1999-07-02.00:00:00 last changed 171 months ago
Rationale:
Implementors can make minor changes and the example will work. Users are not affected in any case.
According to John Spicer, It is possible to explicitly instantiate these operators using different syntax: change "std::operator+<float>" to "std::operator+".
The proposed resolution of issue 120 is that users will not be able to explicitly instantiate standard library templates. If that resolution is accepted then library implementors will be the only ones that will be affected by this problem, and they must use the indicated syntax.
A user who tries to explicitly instantiate a complex non-member operator will get compilation errors. Below is a simplified example of the reason why. The problem is that iterator_traits cannot be instantiated on a non-pointer type like float, yet when the compiler is trying to decide which operator+ needs to be instantiated it must instantiate the declaration to figure out the first argument type of a reverse_iterator operator.
namespace std { template <class Iterator> struct iterator_traits { typedef typename Iterator::value_type value_type; }; template <class T> class reverse_iterator; // reverse_iterator operator+ template <class T> reverse_iterator<T> operator+ (typename iterator_traits<T>::difference_type, const reverse_iterator<T>&); template <class T> struct complex {}; // complex operator + template <class T> complex<T> operator+ (const T& lhs, const complex<T>& rhs) { return complex<T>();} } // request for explicit instantiation template std::complex<float> std::operator+<float>(const float&, const std::complex<float>&);
See also c++-stdlib reflector messages: lib-6814, 6815, 6816.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg1758 |
1999-07-02 00:00:00 | admin | create |