[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
how does template<template<...> op> function(op<...>) work?
From: |
Piotr Sawuk |
Subject: |
how does template<template<...> op> function(op<...>) work? |
Date: |
08 Aug 2007 21:53:32 GMT |
Iis there some problem with type-matching of template template-parameters?
Is there any error/misunderstanding on my side?
In g++ 4.1.2 I get "no matching function for call to ... operator="
when I compile "o=o*i;" with
#include <algorithm>
template<typename iter_, typename val_>
struct stl_algorithm_class
{//class encapsulating all stl-algorithms operating on iterator-ranges...
template<class op_,typename iter2_=iter_>
class stl_binary_operation
{
stl_algorithm_class<iter_> v1;
stl_algorithm_class<iter2_> v2;
public:
stl_binary_operation(stl_algorithm_class<iter_> v,
stl_algorithm_class<iter2_> w) : v1(v),
v2(w) {}
template<typename iter3_>
iter3_ operator()(stl_algorithm_class<iter3_> o)
{return std::transform(v1.start,v1.tail,v2.start,o.start,
op_());}
};
template<class op_,typename iter2_>
class stl_unary_operation
{//similar
};
iter_ start,tail;
stl_algorithm_class(const iter_& s, const iter_& e) : start(s), tail(e)
{}
template<typename iter2_,typename val2_>
iter_ operator=(const stl_algorithm_class<iter2_,val2_>& t)
{return std::copy(t.start,t.tail,start);}
template<template<class,typename> class stl_operator_,class iter2_,
typename val1_,class op_, typename val2_>
iter_ operator=(typename stl_algorithm_class<iter2_,val1_>::template
stl_operator_<op_,val2_>& o)
{return o(*this);}
template<typename iter2_>
friend stl_binary_operation<std::multiplies<val_>,iter2_ >
operator*(const stl_algorithm_class<iter_>& a,
const stl_algorithm_class<iter2_>& b)
{return stl_binary_operation<std::multiplies<val_> ,iter2_>(a,b);}
};
int n(16),s1[16],s2[16];
stl_algorithm_class<int*,int> i(s1,s1+n),o(s2,s2+n);
--
Better send the eMails to netscape.net, as to
evade useless burthening of my provider's /dev/null...
P
- how does template<template<...> op> function(op<...>) work?,
Piotr Sawuk <=