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

  • Home
  • SEARCH
  • 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 5989935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:10:19+00:00 2026-05-22T23:10:19+00:00

I am compiling the same project under two different compilers. The snippet below compiles

  • 0

I am compiling the same project under two different compilers. The snippet below compiles fine under VS2008 but gives the following error when I try to compile it under G++ with Eclipse

G++ Error message:

common.h: In function 'int ci_find_substr(const T&, const T&, const std::locale&)':
common.h:84: error: expected `;' before 'it'
common.h:86: error: 'it' was not declared in this scope

Source code snippet

#include <stdio.h>
#include <string.h>
#include <stdarg.h>

#include <string>
#include <algorithm>
#include <locale>
#include <iostream>
#include <algorithm>  

using namespace std ; 

// templated version of my_equal so it could work with both char and wchar_t
template<typename charT>
struct my_equal {
    my_equal( const std::locale& loc ) : loc_(loc) {}
    bool operator()(charT ch1, charT ch2) {
        return std::toupper(ch1, loc_) == std::toupper(ch2, loc_);
    }
private:
    const std::locale& loc_;
};

// find substring (case insensitive)
template<typename T>
int ci_find_substr( const T& str1, const T& str2, const std::locale& loc = std::locale() )
{
    T::const_iterator it = std::search( str1.begin(), str1.end(),
        str2.begin(), str2.end(), my_equal<T::value_type>(loc) );
    if ( it != str1.end() ) return it - str1.begin();
    else return -1; // not found
}

Any help, suggestions, or hints would help.
Thanks.

  • 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-22T23:10:20+00:00Added an answer on May 22, 2026 at 11:10 pm

    Try putting typename T::const_iterator it = std::search(etc.) I don’t think it’s recognizing T::const_iterator as a type.

    When I tried to compile your code in g++ 4.5.2, it gave me the following error message, which confirms this

    error: need 'typename' before 'T:: const_iterator' because 'T' is a dependent scope
    

    Edit: You also need it on the my_equal<T::value_type>(loc). Should be changed to my_equal<typename T::value_type>(loc)

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

Sidebar

Related Questions

I've been hitting a java.lang.OutOfMemoryError: PermGen error when compiling a project with ant under
What we are looking for is: while compiling the same configuration, say Release|Win32, is
Are there techniques for comparing the same data stored in different schemas? The situation
After compiling a simple C++ project using Visual Studio 2008 on vista, everything runs
When compiling the following simpleType with the XJC compile (from the JAXB package)... <xs:simpleType
I am getting the following error message when compiling or attempting to run my
I have a grails project with some additional java source files under src/java folder.
I'm running Eclipse Europa (3.3). I leave the Build Automatically setting, under the Project
I want to accelerate the compilation of a large Flash IDE project by pre-compiling
Compiling a C++ file takes a very long time when compared to C# and

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.