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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:54:01+00:00 2026-06-12T22:54:01+00:00

Say that I have some user-defined complex struct, like struct usrStruct{ double a; T1

  • 0

Say that I have some user-defined complex struct, like

struct usrStruct{
     double a;
     T1 b;
     T2 c;
     /* and so on...*/
}

which is used as a basic element for a std::vector, std::list or anything iterable..

Say that the std::vector<usrStruct> is passed to a function of mine through iterators

  template<class InputIterator>  
  T myFoo( InputIterator first, InputIterator last ){ /*...*/ }.

Q: Is there a standard way to override operator*() of the InputIterator, (in this case of std::vector<usrStruct>::iterator ) so that myFoo just interacts with the member a?

i.e., so that

  *first == (*first).a;

and thus myFoo works orthogonally with respect to the whole definition of usrStruct?

Thank you.

  • 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-12T22:54:02+00:00Added an answer on June 12, 2026 at 10:54 pm

    No, you cannot do that. You can make your struct implicitly convertible to a double (via operator double). Or you can allow direct comparisons by overloading operator==(usrSruct,double) and/or operator==(double,usrStruct).

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

Sidebar

Related Questions

Let's say I have a subroutine/method that a user can call to test some
In PHP, say that you have some code like this: $infrastructure = mt_rand(0,100); if
I have read from some article that say's Apple doesn't approve the application which
Let's say I have some grid that looks like this _ _ _ _
Let's say I have some code (using CherryPy) that looks like this: import cherrypy
let's say that I have some <TR style = background-color : red ;> and
Let's say that I have class , that uses some functionality of dict .
Say I have some 10 categories that I need to reference in a web
Let's say I have some model objects that resemble this: public class FooModel {
Let's say I have some Control that has been disabled. It contains a bunch

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.