Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 403705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:14:28+00:00 2026-05-12T17:14:28+00:00

Actually I’ve a problem with compiling some library with intel compiler. This same library

  • 0

Actually I’ve a problem with compiling some library with intel compiler.

This same library has been compiled properly with g++.

Problem is caused by templates.
What I’d like to understand is the declaration of
**typename** as not template function parameter and variable declaration inside function body

example:

void func(typename sometype){..
...
typename some_other_type;
..
}

Compilation this kind of code produce following errors (intel),(gcc doesn’t claim):
I’ve got following errors

../../../libs/log/src/attribute_set.cpp(415): error: no operator "!=" matches these operands
            operand types are: boost::log_st::basic_attribute_set<wchar_t>::iter<'\000'> != boost::log_st::basic_attribute_set<wchar_t>::iter<'\000'>
      while (begin != end)
                   ^
          detected during instantiation of "void boost::log_st::basic_attribute_set<CharT>::erase(boost::log_st::basic_attribute_set<CharT>::iter<'\000'>, boost::log_st::basic_attribute_set<CharT>::iter<'\000'>) [with CharT=wchar_t]" at line 438

../../../boost/log/attributes/attribute_set.hpp(115): error: no operator "!=" matches these operands
            operand types are: boost::log_st::basic_attribute_set<wchar_t>::iter<'\000'> != boost::log_st::basic_attribute_set<wchar_t>::iter<'\000'>
              if (it != m_pContainer->end())

What I’d like to understand is the usage of the typename inside the body of functions, parameter declarations.

ex.:

template< typename CharT >
struct basic_attribute_values_view< CharT >::implementation
{

public:
..
..
void adopt_nodes( **typename attribu**te_set_type::const_iterator& it, **typename attribut**e_set_type::const_iterator end)
    {
        for (; it != end; ++it)
            push_back(it->first, it->second.get());
    }

in different file I’ve:

template< typename CharT >
class basic_attribute_set
{
    friend class basic_attribute_values_view< CharT >;

    //! Self type
    typedef basic_attribute_set< CharT > this_type;

public:
    //! Character type
    typedef CharT char_type;
    //! String type
    typedef std::basic_string< char_type > string_type;
    //! Key type
    typedef basic_slim_string< char_type > key_type;
    //! Mapped attribute type
    typedef shared_ptr< attribute > mapped_type;

    //! Value type
    typedef std::pair< const key_type, mapped_type > value_type;
    //! Allocator type
    typedef std::allocator< value_type > allocator_type;
    //! Reference type
    **typedef typename allocator_type::reference reference;**
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:14:29+00:00Added an answer on May 12, 2026 at 5:14 pm

    You need to use typename for so-called “dependent types”. Those are types that depend on a template argument and are not known until the template is instantiated. It’s probably best explained using an example:

    struct some_foo {
      typedef int bar;
    };
    
    template< typename Foo >
    struct baz {
      typedef Foo::bar barbar; // wrong, shouldn't compile
    
      barbar f(); // would be fine if barbar were a type
    
      // more stuff...
    };
    

    That typedef defining barbar is one that requires a typename in order for the compiler to be able to check the template for blatant syntactic errors before it is instantiated with a concrete type. The reason is that, when the compiler sees the template for the first time (when it’s not instantiated with concrete template parameters yet), the compiler doesn’t know whether Foo::bar is a type. For all it know, I might intent baz to be instantiated with types like this one

    struct some_other_foo {
      static int bar;
    };
    

    in which case Foo::bar would refer to an object, not a type, and the definition of baz::bar would be syntactic nonsense. Without knowing whether Foo::bar refers to a type, the compiler has no chance to check anything within baz that’s directly or indirectly using barbar for even the most stupid typos until baz is instantiated. Using the proper typename, baz looks like this:

    template< typename Foo >
    struct baz {
      typedef typename Foo::bar barbar;
    
      barbar f();
    
      // more stuff...
    };
    

    Now the compiler at least knows that Foo::bar is supposed to be the name of a type, which makes barbar a type name, too. So the declaration of f() is syntactical OK, too.

    By the way, there’s a similar problem with templates instead of types:

    template< typename Foo >
    struct baz {
      Foo::bar<Foo> create_wrgl(); // wrong, shouldn't compile
    };
    

    When the compiler “sees” Foo::bar it doesn’t know what it is, so bar<Foo could just as well be a comparison, leaving the compiler confused about the trailing >. Here, too, you need to give the compiler a hint that Foo::bar is supposed to be the name of a template:

    template< typename Foo >
    struct baz {
      Foo::template bar<Foo> create_wrgl();
    };
    

    Beware: Notably Visual C++ still doesn’t implement proper two-phase lookup (in essence: it doesn’t really check templates until they are instantiated). Therefor it often accepts erroneous code that misses a typename or a template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 367k
  • Answers 367k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, your two routes are conflicting with your mapped resource… May 14, 2026 at 4:48 pm
  • Editorial Team
    Editorial Team added an answer Oops - nevermind. I changed XPath to this: string strXPath… May 14, 2026 at 4:48 pm
  • Editorial Team
    Editorial Team added an answer You can use a serialization callback. Add the following method… May 14, 2026 at 4:48 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.