Boost logo

Boost Users :

From: chun ping wang (cablepuff_at_[hidden])
Date: 2007-11-04 01:38:19


Hi I have a problem with boost::function in association with template.

I have a gain function declaration declare as this..
template <
         template <typename ELEM,typename = std::allocator<ELEM> >
         class CONT,
         typename T,
         typename U
>
    long double gain(const CONT<boost::unordered_map<T, U> >& data,
const T& attr, const T& target_attr);
// old signature does compile
 template <
          template <typename ELEM,typename = std::allocator<ELEM> >
          class CONT,
          typename T,
          typename U
>
    boost::any ID3(
        const CONT<boost::unordered_map<T, U> >&,
        const T&,
        const CONT<T> &,
        boost::function<long double (const
CONT<boost::unordered_map<T, U> >&, const T&, const T&) >
    );

// new signature DOES NOT compile.
 template <
          template <typename ELEM,typename = std::allocator<ELEM> >
          class CONT,
          typename T,
          typename U
>
    boost::any ID3(
        const CONT<boost::unordered_map<T, U> >&,
        const T&,
        CONT<T> *,
        boost::function<long double (const
CONT<boost::unordered_map<T, U> >&, const T&, const T&) >
    );

In the main file i have things pass as this.
// old way of passing works with old signature
boost::any tree(
           MyAnn::ID3<std::vector, std::string, std::string>(data,
target_attr, attribute,
           MyAnn::gain<std::vector, std::string, std::string>)
        );
// line 76 to 82.
boost::function<long double (const
std::vector<boost::unordered_map<std::string, std::string>&, const
std::string&,
                const std::string&)> gainfunc;
        gainfunc = MyAnn::gain<std::vector, std::string, std::string>;
        boost::any tree(
           MyAnn::ID3<std::vector, std::string, std::string>(data,
target_attr, boost::addressof(attribute),
           gainfunc)
        );

I compile the file and get teh following errors. Can anyone tell me
why changing the orginial signature from const CONT<T>& to CONT<T> *
all of sudden breaks the code. Thanks.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net