J
jsnX
i want a function object that is
a) initialized with an STL container foo
b) will search foo for an object of type foo::value_type
here is my code:
========================================================================
/* if we have a big list of things, and we went to check it
* over and over for this or that thing, then we can use this
* object to cache the list and consolidate queries of it.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 template<class T>
17 class is_in : public unary_function<T::value_type, bool>
18 {
19 private:
20 T::iterator a;
21 T::iterator z;
22
23 public:
24 is_in(const T& t) : a( t.begin() ), z( t.end() )
25 {}
26
27 is_in(const T::iterator& a, const T::iterator& z ) : a(a), z(z)
28 {}
29
30 bool
31 operator() (const T::value_type& tau)
32 {
33 return std::find(a, z, tau) != z;
34 }
35 };
=======================================================================
however, this code does not compile:
====================error=messages=piped=through=gfilt=================
is_in.cpp:17: error: expected template-name before '<
' token
is_in.cpp:17: error: expected `{' before '<
' token
is_in.cpp:17: error: expected unqualified-id before '<
' token
is_in.cpp:17: error: expected `;' before '<
' token
Process gfilt exited with code 1
=======================================================================
can someone tell me why my code won't go? it certainly *looks* legal.
thanks,
_jsnX
a) initialized with an STL container foo
b) will search foo for an object of type foo::value_type
here is my code:
========================================================================
/* if we have a big list of things, and we went to check it
* over and over for this or that thing, then we can use this
* object to cache the list and consolidate queries of it.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 template<class T>
17 class is_in : public unary_function<T::value_type, bool>
18 {
19 private:
20 T::iterator a;
21 T::iterator z;
22
23 public:
24 is_in(const T& t) : a( t.begin() ), z( t.end() )
25 {}
26
27 is_in(const T::iterator& a, const T::iterator& z ) : a(a), z(z)
28 {}
29
30 bool
31 operator() (const T::value_type& tau)
32 {
33 return std::find(a, z, tau) != z;
34 }
35 };
=======================================================================
however, this code does not compile:
====================error=messages=piped=through=gfilt=================
BD Software STL Message Decryptor v2.47 for gccgfilt -ansi is_in.cpp
is_in.cpp:17: error: expected template-name before '<
' token
is_in.cpp:17: error: expected `{' before '<
' token
is_in.cpp:17: error: expected unqualified-id before '<
' token
is_in.cpp:17: error: expected `;' before '<
' token
Process gfilt exited with code 1
=======================================================================
can someone tell me why my code won't go? it certainly *looks* legal.
thanks,
_jsnX