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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:36:28+00:00 2026-05-31T13:36:28+00:00

This compiles fine in MSVC but gcc complains. The code on ideone . I

  • 0

This compiles fine in MSVC but gcc complains. The code on ideone. I don’t understand what is wrong by passing the iterators by reference.

The error

prog.cpp: In function ‘void FindType()’:
prog.cpp:8: error: no matching function for call to ‘FindType(__gnu_cxx::__normal_iterator<Var**, std::vector<Var*, std::allocator<Var*> > >, __gnu_cxx::__normal_iterator<Var**, std::vector<Var*, std::allocator<Var*> > >)’
prog.cpp:4: note: candidates are: void FindType(__gnu_cxx::__normal_iterator<Var**, std::vector<Var*, std::allocator<Var*> > >&, __gnu_cxx::__normal_iterator<Var**, std::vector<Var*, std::allocator<Var*> > >&)
prog.cpp:5: note:                 void FindType()
prog.cpp:8: error: return-statement with a value, in function returning 'void'

The code

#include <vector>
using namespace std;
class Var {};
void FindType(vector<Var*>::iterator&b, vector<Var*>::iterator&e){}
void FindType()
{
        vector<Var*> ls;
        return FindType(ls.begin(), ls.end());
}
  • 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-31T13:36:28+00:00Added an answer on May 31, 2026 at 1:36 pm

    Pass const references. The .begin() and .end() calls return rvalues.

    Revision: However, as you have observed in the comments below, you cannot do ++b if b is a const reference. Your idea below seems best in that case: pass that iterator by value.

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

Sidebar

Related Questions

This code compiles fine with GCC and Clang but not with MSVC 2010: #include
I'm having a hard time using std::string::iterators in C++. This code compiles fine (still
This compiles fine in GCC 3 and 4. MSVC++ can't figure out the type
This compiles fine in Visual studio, but why not in XCode? class A() {};
This code compiles fine: {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, FlexibleContexts, EmptyDataDecls, ScopedTypeVariables, TypeOperators,
The following compiles fine: Object o = new Object(); System.out.println(o instanceof Cloneable); But this
Please check this code out it compiles and runs absolutely fine.. The question is
This compiles perfectly fine with the current MSVC compiler: struct Foo { } const
I have this map which compiles fine in MSVC10 : std::map<std::string, std::ofstream> m_logFiles; But
I think the problem is in main() but this compiles fine but I get

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.