H
Hendrik Schober
Hi,
I'm having two overloaded function templates,
#include <iterator>
template< typename T >
void test( T /*a1*/, T /*a2*/ ) {}
template< typename Iter >
void test( Iter /*b*/, Iter /*e*/ ) {}
which I need to call. (In reality, these are constructors,
in case that matters.) Unfortunately, the compiler isn't
as clever and can't tell 'T' from 'Iter', so I have to
give it a hint whether what gets passed is an iterator.
But my attempt to use SFINAE for this
template< typename Iter, class ItTr >
void test( Iter /*b*/, Iter /*e*/
, ItTr = std::iterator_traits<Iter>() ) {}
doesn't work, since this completely removed the iterator
overload from the set the compiler considered. Or that's
what I figured because this
#include <iterator>
//template< typename T >
//void test( T /*a1*/, T /*a2*/ ) {}
template< typename Iter, class ItTr >
void test( Iter /*b*/, Iter /*e*/
, ItTr = std::iterator_traits<Iter>() ) {}
int main()
{
const int fa[] = { 255, 255, 255, 255 };
//test(0,1);
test(fa, fa+4);
return 0;
}
doesn't compile.
Now I'm stumped. I thought I had done this before, so I am
probably making something stupid here. (It's already passed
6pm here...)
Anyone out there?
TIA,
Schobi
I'm having two overloaded function templates,
#include <iterator>
template< typename T >
void test( T /*a1*/, T /*a2*/ ) {}
template< typename Iter >
void test( Iter /*b*/, Iter /*e*/ ) {}
which I need to call. (In reality, these are constructors,
in case that matters.) Unfortunately, the compiler isn't
as clever and can't tell 'T' from 'Iter', so I have to
give it a hint whether what gets passed is an iterator.
But my attempt to use SFINAE for this
template< typename Iter, class ItTr >
void test( Iter /*b*/, Iter /*e*/
, ItTr = std::iterator_traits<Iter>() ) {}
doesn't work, since this completely removed the iterator
overload from the set the compiler considered. Or that's
what I figured because this
#include <iterator>
//template< typename T >
//void test( T /*a1*/, T /*a2*/ ) {}
template< typename Iter, class ItTr >
void test( Iter /*b*/, Iter /*e*/
, ItTr = std::iterator_traits<Iter>() ) {}
int main()
{
const int fa[] = { 255, 255, 255, 255 };
//test(0,1);
test(fa, fa+4);
return 0;
}
doesn't compile.
Now I'm stumped. I thought I had done this before, so I am
probably making something stupid here. (It's already passed
6pm here...)
Anyone out there?
TIA,
Schobi