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 8395165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:13:53+00:00 2026-06-09T20:13:53+00:00

when compiling with mingw32-g++, there is error: no matching function for call to ‘for_each(int

  • 0

when compiling with mingw32-g++, there is error: no matching function for call to ‘for_each(int [9], int*, main()::Output)’, but can do well in vs2005?

#include <iostream>
#include <algorithm>

int main() {

  struct Output {
      void  operator () (int v) {
           std::cout << v << std::endl; 
       }
  };

  int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  std::for_each(a, a + sizeof(a)/sizeof(a[0]), Output());

  return 0;
}
  • 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-06-09T20:13:54+00:00Added an answer on June 9, 2026 at 8:13 pm

    In pre-C++11 version of the language types used as template arguments were required to have linkage. Local class declarations in C++ have no linkage, which is why they can’t be used as template arguments in C++98/C++03. In those versions of the language you have to declare your class in namespace scope.

    The linkage requirement was removed in C++11. Your code is valid from C++11 point of view. Apparently, you are compiling in pre-C++11 mode.

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

Sidebar

Related Questions

When compiling a c file that uses old style function definition like int foo(a)
Compiling this code int main(int argc, char **argv) { int xor = 0; }
Compiling error Incompatible types - found java.lang.Object but expected E is generated when I
Compiling the file main.c with: gcc main1.c -o final gives me: /tmp/cc1cwhAP.o: In function
While compiling a project i get the following error as c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find lwxmsw28
In compiling qt I found that there is a qws target called arm-linux-gcc. I
When compiling with gmcs on Linux, how can I set the explorer icon the
Compiling polygone.h and polygone.cc gives error: polygone.cc:5:19: error: expected constructor, destructor, or type conversion
How to configure mingw32 to cross-compile Direct3D Apps for Windows? Is there any possibility?
I have attempted compiling libgcrypt 1.5.0 with MinGW32 on Windows 7 to no avail.

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.