www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Funky DMC++ template bug

↑ ↓ ← "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
↑ ↓ "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
↑ ↓ → "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