www.digitalmars.com         C & C++   DMDScript  

c++ - Funky DMC++ template bug

reply "Matthew Wilson" <dmd synesis.com.au> writes:
Trying to compile the std_mem_fun_t from COMSTL with DMC++ and it's not
behaving itself.

The template is defined as

template< cs_typename_param_k T
        , cs_typename_param_k R
        >
class std_mem_fun_t
    : public comstl_ns_qual_std(unary_function)<R (STDAPICALLTYPE T::*)(),
R>
{
public:
    typedef R                               return_type;
    typedef T                               operand_class_type;
    typedef return_type (STDAPICALLTYPE T::*argument_type)();

public:
    /// \brief Constructor
    ///
    /// \param pmfn The function (pointer to member of T, returning R) which
will be applied to the objects
    explicit std_mem_fun_t(argument_type pmfn)
        : m_pmfn(pmfn)
    {}

    /// \brief Function call operator
    ///
    /// \param pt The object pointer on which to apply the function
    return_type operator ()(operand_class_type *pt) const
    {
        return (pt->*m_pmfn)();
    }

private:
    argument_type m_pmfn;
};

then when I try to use it as in

 for_each(items.begin(), items.end(), comstl::std_mem_fun_t<IUnknown,
ULONG>(&IUnknown::Release));

it gives

Compiling .\comstl\functionals_test\functionals_test.cpp
        comstl_ns_qual_std(for_each)(items.begin(), items.end(),
comstl_ns_qual(std_mem_fun_t)<IUnknown, ULONG>(&IUnknown::Release));

          ^
comstl\functionals_test\functionals_test.cpp(88) : Error: cannot find
constructor for class matching
stlsoft::comstl_project::std_mem_fun_t<>::stlsoft::comstl_project::std_mem_f
un_t<>(unsigned long ( IUnknown::*std func)())
--- errorlevel 1

--- errorlevel 1

 This works fine on Borland, Intel, MSVC, Metrowerks, so my working
hypothesis is that DMC++ has the problem.

Any clues'd be greatly appreciated. I'd be perfectly content with a
workaround.

Matthew
Apr 07 2003
parent reply "Walter" <walter digitalmars.com> writes:
Could you make a small, standalone example?

"Matthew Wilson" <dmd synesis.com.au> wrote in message
news:b6rt01$1gbg$1 digitaldaemon.com...
 Trying to compile the std_mem_fun_t from COMSTL with DMC++ and it's not
 behaving itself.

 The template is defined as

 template< cs_typename_param_k T
         , cs_typename_param_k R
         >
 class std_mem_fun_t
     : public comstl_ns_qual_std(unary_function)<R (STDAPICALLTYPE T::*)(),
 R>
 {
 public:
     typedef R                               return_type;
     typedef T                               operand_class_type;
     typedef return_type (STDAPICALLTYPE T::*argument_type)();

 public:
     /// \brief Constructor
     ///
     /// \param pmfn The function (pointer to member of T, returning R)

 will be applied to the objects
     explicit std_mem_fun_t(argument_type pmfn)
         : m_pmfn(pmfn)
     {}

     /// \brief Function call operator
     ///
     /// \param pt The object pointer on which to apply the function
     return_type operator ()(operand_class_type *pt) const
     {
         return (pt->*m_pmfn)();
     }

 private:
     argument_type m_pmfn;
 };

 then when I try to use it as in

  for_each(items.begin(), items.end(), comstl::std_mem_fun_t<IUnknown,
 ULONG>(&IUnknown::Release));

 it gives

 Compiling .\comstl\functionals_test\functionals_test.cpp
         comstl_ns_qual_std(for_each)(items.begin(), items.end(),
 comstl_ns_qual(std_mem_fun_t)<IUnknown, ULONG>(&IUnknown::Release));

           ^
 comstl\functionals_test\functionals_test.cpp(88) : Error: cannot find
 constructor for class matching

 un_t<>(unsigned long ( IUnknown::*std func)())
 --- errorlevel 1

 --- errorlevel 1

  This works fine on Borland, Intel, MSVC, Metrowerks, so my working
 hypothesis is that DMC++ has the problem.

 Any clues'd be greatly appreciated. I'd be perfectly content with a
 workaround.

 Matthew

Apr 07 2003
parent "Matthew Wilson" <dmd synesis.com.au> writes:
I'll try, but it's pretty much down to the bone as I've included here. I'll
post another shortly.

"Walter" <walter digitalmars.com> wrote in message
news:b6sk93$dao$3 digitaldaemon.com...
 Could you make a small, standalone example?

 "Matthew Wilson" <dmd synesis.com.au> wrote in message
 news:b6rt01$1gbg$1 digitaldaemon.com...
 Trying to compile the std_mem_fun_t from COMSTL with DMC++ and it's not
 behaving itself.

 The template is defined as

 template< cs_typename_param_k T
         , cs_typename_param_k R
         >
 class std_mem_fun_t
     : public comstl_ns_qual_std(unary_function)<R (STDAPICALLTYPE


 R>
 {
 public:
     typedef R                               return_type;
     typedef T                               operand_class_type;
     typedef return_type (STDAPICALLTYPE T::*argument_type)();

 public:
     /// \brief Constructor
     ///
     /// \param pmfn The function (pointer to member of T, returning R)

 will be applied to the objects
     explicit std_mem_fun_t(argument_type pmfn)
         : m_pmfn(pmfn)
     {}

     /// \brief Function call operator
     ///
     /// \param pt The object pointer on which to apply the function
     return_type operator ()(operand_class_type *pt) const
     {
         return (pt->*m_pmfn)();
     }

 private:
     argument_type m_pmfn;
 };

 then when I try to use it as in

  for_each(items.begin(), items.end(), comstl::std_mem_fun_t<IUnknown,
 ULONG>(&IUnknown::Release));

 it gives

 Compiling .\comstl\functionals_test\functionals_test.cpp
         comstl_ns_qual_std(for_each)(items.begin(), items.end(),
 comstl_ns_qual(std_mem_fun_t)<IUnknown, ULONG>(&IUnknown::Release));

           ^
 comstl\functionals_test\functionals_test.cpp(88) : Error: cannot find
 constructor for class matching


 un_t<>(unsigned long ( IUnknown::*std func)())
 --- errorlevel 1

 --- errorlevel 1

  This works fine on Borland, Intel, MSVC, Metrowerks, so my working
 hypothesis is that DMC++ has the problem.

 Any clues'd be greatly appreciated. I'd be perfectly content with a
 workaround.

 Matthew


Apr 07 2003