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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:39:34+00:00 2026-05-27T00:39:34+00:00

The python keyword yield has been a great conceptual abstraction for me, allowing me

  • 0

The python keyword yield has been a great conceptual abstraction for me, allowing me to distill the important parts of an algorithm to human-readable form. We have previously discussed:

Python generators in various languages

where an answer was given for a windows only library in C++. In addition I’ve found another example using a funky macro expansion in the question:

Generators in C++ — invalid use of nonstatic data member

The edge of my computer science knowledge tells me that a yield function has something to do with co-routines and monads, but I’m not quite how this fits into what C++ or C++0x can accomplish.

It seems that in C++, without the using of a macro-expansion or a windows only fiber (thread), yeild can not be implemented. Is this true? Does the question change with the additional language features of C++0x?

  • 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-27T00:39:35+00:00Added an answer on May 27, 2026 at 12:39 am

    You can map yield python mechanism to C++ iterators.

    See Boost Function Input Iterator and the example:

    The Function Input Iterator allows for creating iterators that encapsulate a nullary function object and a state object which tracks the number of times the iterator has been incremented. A Function Input Iterator models the InputIterator concept and is useful for creating bounded input iterators.

    Like the Generator Iterator, the Function Input Iterator takes a function that models the Generator concept (which is basically a nullary or 0-arity function object). Each increment of the function Function Input Iterator invokes the generator function and stores the value in the iterator. When the iterator is dereferenced the stored value is returned.

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

Sidebar

Related Questions

What functionality does the yield keyword in Python provide? For example, I'm trying to
What is the difference between yield keyword in Python and yield keyword in C#?
I'm reading about the yield keyword in python, and trying to understand running this
What is the python keyword with used for? Example from: http://docs.python.org/tutorial/inputoutput.html >>> with open('/tmp/workfile',
Is there anything in Python that works like the final keyword in Java -
I'm dreaming of a Python method with explicit keyword args: def func(a=None, b=None, c=None):
Python has this wonderful way of handling string substitutions using dictionaries: >>> 'The %(site)s
How can you use the python exec keyword inside functions?
I have Python code that uses the with keyword (new in 2.6) and I
What is the best style for a Python method that requires the keyword argument

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.