1

I have

    template <typename ConcContainer>
    class WebBrowsingPolicyData
    {
    public:
        typedef ConcContainer<std::shared_ptr<WBRuleDetails>>::iterator iterator;
    ...
    private:
    ConcContainer<std::shared_ptr<WBRuleDetails>> usersData_;
    CRITICAL_SECTION critSection

I get a compile error at line (Error 6 error C2238: unexpected token(s) preceding ';')

typedef ConcContainer<std::shared_ptr<WBRuleDetails>>::iterator iterator

How can I make a typedef inside the template ? I must be missing something..

2
  • This looks confusing: Is ConcContainer a typename or a template?
    – aschepler
    Nov 16, 2011 at 14:49
  • ConcContainer is actually a template that's why hmjd answer is valid
    – Ghita
    Nov 17, 2011 at 6:28

2 Answers 2

3

ConContainer is itself a template so it needs to be a template template parameter:

template <template <typename T> class ConcContainer>
class WebBrowsingPolicyData
{
public:
    typedef typename ConcContainer<std::shared_ptr<WBRuleDetails>>::iterator iterator;
};
0
0

Two possibilities:

  1. The compiler is having trouble with >>. Insert a space. Note that if you're using a C++11-conformant compiler, this should not be an issue.

example:

typedef ConcContainer<std::shared_ptr<WBRuleDetails> >::iterator iterator;
  1. ConcContainer doesn't have a member or typedef iterator. Check to make sure that it really does.

EDIT: This is not the most vexing parse.

3
  • I have conformant compiler VC 2010. I am not instantiating there the WebBrowsingPolicy...So must be something else.
    – Ghita
    Nov 16, 2011 at 14:51
  • Pretty sure that's not the most vexing parse: en.wikipedia.org/wiki/Most_vexing_parse
    – obmarg
    Nov 16, 2011 at 14:51
  • @obmarg: Well, whadya know! You're right -- I've always thought of this incorrectly. Edited. Nov 16, 2011 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.