Menu

#13 Compilation error in Visual C++ 2005 - missing typename

v1.0_(example)
open
nobody
None
5
2006-01-02
2006-01-02
Anonymous
No

I have quite complex project, where I include first my
Base.hpp header (which includes cmath, string,
algorithm, limits and windows.h with
WIN32_LEAN_AND_MEAN and NOMINMAX and muse be included
first because it is precompiled header) and then
sigslot.h. I encounter compilation error:

sigslot.h(419) : warning C4346:
'std::set<sigslot::_signal_base<mt_policy>*>::const_iterator'
dependent name is not a type
prefix with 'typename' to indicate a type
sigslot.h(476) : see reference to class template
instantiation 'sigslot::has_slots<mt_policy>' being
compiled
sigslot.h(419) : error C2146: syntax error : missing
';' before identifier 'const_iterator'
sigslot.h(419) : error C4430: missing type specifier -
int assumed. Note: C++ does not support default-int

in line 419:

typedef sender_set::const_iterator const_iterator;

Description of this error:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcerrCompilerWarningLevel1C4346.asp

When I change this line into:

typedef typename sender_set::const_iterator const_iterator;

everything is OK.

--
Adam Sawicki
regedit@risp.pl
www.regedit.risp.pl

Discussion

  • Nobody/Anonymous

    Logged In: NO

    The same error occurs in MSVC 2003 and the fix is also the same.

    --
    Mark Rebane

     
  • Nobody/Anonymous

    Logged In: NO

    Line 414:
    template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
    class has_slots : public mt_policy
    {
    private:
    typedef std::set<_signal_base<mt_policy> *> sender_set;
    //###

    public:
    has_slots()
    {
    ;
    }

    has_slots(const has_slots& hs)
    mt_policy(hs)
    {
    lock_block<mt_policy> lock(this);
    sender_set::const_iterator it = hs.m_senders.begin();
    sender_set::const_iterator itEnd = hs.m_senders.end();

    while(it != itEnd)
    {
    (*it)->slot_duplicate(&hs, this);
    m_senders.insert(*it);
    ++it;
    }
    }

    void signal_connect(_signal_base<mt_policy>* sender)
    {
    lock_block<mt_policy> lock(this);
    m_senders.insert(sender);
    }

    void signal_disconnect(_signal_base<mt_policy>* sender)
    {
    lock_block<mt_policy> lock(this);
    m_senders.erase(sender);
    }

    virtual ~has_slots()
    {
    disconnect_all();
    }

    void disconnect_all()
    {
    lock_block<mt_policy> lock(this);
    sender_set::const_iterator it = m_senders.begin();
    sender_set::const_iterator itEnd = m_senders.end();

    while(it != itEnd)
    {
    (*it)->slot_disconnect(this);
    ++it;
    }

    m_senders.erase(m_senders.begin(), m_senders.end());
    }

    private:
    sender_set m_senders;
    };

     

Log in to post a comment.

MongoDB Logo MongoDB