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 116689

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:13:04+00:00 2026-05-11T03:13:04+00:00

Why is it impossible to have a reference to void? The only thing I

  • 0

Why is it impossible to have a reference to void? The only thing I found in the C++ Standard is this line, at 8.3.2.1

A declarator that specifies the type ‘reference to cv void’ is ill-formed.

Why is it that way? Why can’t I write a ‘generic’ function that accept a void&?

Just to be clear, I have no useful application in mind where using a reference-to-void could be better than using templates, but I’m just curious about the rationale for forbidding this construct.


To clarify a little, I understand that using a reference-to-void ‘as is’ would be as meaningless as dereferencing a pointer-to-void. However, I could cast it to a reference-to-sometype in order to use it, couldn’t I? In fact, I don’t see why the following snippet can work…

void foo(void *data) {     int *i = reinterpret_cast<int*>(data);     // do something with i } 

…while this one cannot:

void foo(void &data) {     int &i = reinterpret_cast<int&>(data);     // do something with i } 
  • 0 0 Answers
  • 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. 2026-05-11T03:13:04+00:00Added an answer on May 11, 2026 at 3:13 am

    If you did have a reference to void, what would you do with it? It wouldn’t be a number, or a character, or a pointer, or anything like that. Your hypothetical generic function couldn’t perform any operation on it, except taking its address (and not its size).

    ‘void’ has two uses: to disclaim any knowledge of type (as in void *), and to specify nothing as opposed to something (void function return). In neither case is it possible to say anything about a void something except that it may have an address.

    If you can’t think of a way something can be useful, and I can’t, that is at least evidence that something is useless, and that may well be at least part of the rationale here.

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

Sidebar

Ask A Question

Stats

  • Questions 74k
  • Answers 75k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer There is most probably no real use case for this.… May 11, 2026 at 2:33 pm
  • added an answer I corrected the code in my answer. See Remote File… May 11, 2026 at 2:33 pm
  • added an answer I had not inluded the folder in my classpaths. So… May 11, 2026 at 2:33 pm

Related Questions

We have a problem here. We need to translate a website into multiple language.
Background I have an application written in native C++ over the course of several
I would like to confirm that the following analysis is correct: I am building
Let's say we have a method signature like public static function explodeDn($dn, array &$keys

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.