Re: template specialization problem
abir wrote:
On Jul 8, 5:14 pm, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
abir wrote:
i have a template as shown
template<typename S> class Indexer{};
i want to have a specialization for std::vector both const & non const
version.
template<typename T,typename A> class Indexer<std::vector<T,A> > {}
matches only with nonconst version. anyway to match it for both? and
get if it is const or nonconst?
Const and non-const variation of what? Of a vector? How would you use
it? Give an example that would cause an instantiation of your template.
[..]
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
What i want is to have multiple pattern matching for same
specialization.
I have
template<typename S> class Indexer{};
i have specialization
template<typename T,typename A> class Indexer< std::vector<T,A> > {};
and
template<typename T,typename A> class Indexer < const std::vector<T,A>
{};
Empty classes? I am guessing not, but my crystal ball is malfunctioning
at this time, I can't see into your mind to understand what their
differences or commonalities are.
as both the specialization are nearly same,
Actually as you wrote here, they *are* the same.
> i don't want code
duplication, so i want a single specialization to match both, so that
the client can write,
[..]
(a) "Nearly the same" is not the same as "the same", is it? If there is
a lot in common between two types, extract the common part into the
third class and make it the base class for both.
(b) You didn't answer the question how your class is to be *used*.
Instantiation of a type is not its *use*, you need to show what
*behaviour* your type has to show what exactly you're after.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask