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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:58:35+00:00 2026-06-15T14:58:35+00:00

Without getting into the general exceptions vs error codes discussion, what do you think

  • 0

Without getting into the general exceptions vs error codes discussion, what do you think are the downsides of using std::pair or std:tuple for returning multiple values, namely the function’s return value AND the error/success code, similar to how many Go developers apparently do error handling?

This approach obviously has the advantage of not having to use out parameters for the function return value or error code (depending on which way around you prefer it).

  • 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-15T14:58:36+00:00Added an answer on June 15, 2026 at 2:58 pm

    “what do you think are the downsides of using std::pair or std:tuple for returning multiple values, namely the function’s return value AND the error/success code”

    The main downside of that simplistic (C level) approach to failure handling is a

    • loss of safety.

    I.e. there’s more that can go wrong, such as accessing an indeterminate result value. Or just using a return value when the function didn’t produce a meaningful one.

    The old Barton & Nackman Fallow class solved this safety problem by restricting access to the result value. Essentially the calling code has to check if there is a result value, before using it, and using a logically non-existent result value causes an exception or termination. The boost::optional class does much the same.

    If you don’t want a dependency on Boost, then an Optional class is trivial to implement for POD result type, and at a cost of a little possible inefficiency (dynamic allocation) you can just use a std::vector to carry a non-POD possible result.

    The challenge is to retain the clarity of the calling code, which is the whole point of the exercise…

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

Sidebar

Related Questions

Without getting into a discussion about whether the business logic should be in the
I'm unable to use date (under OS X 10.6, using bash) without getting the
I am getting an error when loading the page without any GET parameters (eg.:
Without getting into to much detail about the actual program,I want to take an
We would like to decrypt data stored in Microsoft Access. Without getting into too
I'm just getting into the Asset Pipeline; I'm using SASS/SCSS, but I'm not understanding
Without getting into OpenGL (Quartz 2D is OK): Let's say I have an image
Without getting into details, I am updating ID3 tags outside of iTunes and would
Without getting into all the javascript for a textfield, I'd like the following validation:
On his blog Scott Kovatch writes: Without getting into too much detail, typing ‘java

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.