 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris Jefferson Guest
|
Posted: Tue Mar 29, 2005 11:37 am Post subject: implementing standard library functions with enable_if |
|
|
Is it valid to implement a standard library function (say find) as:
template<class T, class val>
enable_if<condition find(T,T,const val&);
template<class T, class val>
enable_if<!condition find(T,T,const val&);
I can't see how this would be user visible, but I can't decide if that
means it allowed.
Further, if it was allowed, would it be allowed to have no function
match where the parameters given to find aren't legal (ie T is an
output_iterator)?
Chris
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
Ben Hutchings Guest
|
Posted: Thu Mar 31, 2005 1:17 am Post subject: Re: implementing standard library functions with enable_if |
|
|
Chris Jefferson wrote:
| Quote: | Is it valid to implement a standard library function (say find) as:
template<class T, class val
enable_if find(T,T,const val&);
template<class T, class val
enable_if find(T,T,const val&);
I can't see how this would be user visible, but I can't decide if that
means it allowed.
|
The library-wide requirements on global functions (17.4.4.3) say:
A call to a global function signature described in Clauses 18
through 27 behaves the same as if the implementation declares no
additional global function signatures.
which implies that only the function signatures need to match what
the standard specifies, and not the function templates. So I think
it's allowed.
| Quote: | Further, if it was allowed, would it be allowed to have no function
match where the parameters given to find aren't legal (ie T is an
output_iterator)?
|
Givng a standard template a type argument that doesn't match
requirements set down in the standard results in UB (17.4.3.6/2), and
that includes the possibility of compile-time failure (1.3.12). So
I believe that would be legal.
--
Ben Hutchings
Humans are not rational beings; they are rationalising beings.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
msalters Guest
|
Posted: Thu Mar 31, 2005 5:05 am Post subject: Re: implementing standard library functions with enable_if |
|
|
Chris Jefferson wrote:
| Quote: | Is it valid to implement a standard library function (say find) as:
template<class T, class val
enable_if find(T,T,const val&);
template<class T, class val
enable_if find(T,T,const val&);
I can't see how this would be user visible, but I can't
decide if that means it allowed.
|
Assuming you really mean __condition, and assuming you
mean something like enable_if<...>::type, I'd say it
doesnt matter how a type is named, just which type that
refers to.
Still, I'd expect this to be hidden inside the find
implementation
| Quote: | Further, if it was allowed, would it be allowed to have no
function match where the parameters given to find aren't
legal (ie T is an output_iterator)?
|
Yes, there's no requirement /how/ an implementation has
to diagnose such failures.
HTH,
Michiel Salters
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|