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

The Archive Base Latest Questions

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

The next few lines I’m going to write come from the book The C++

  • 0

The next few lines I’m going to write come from the book “The C++ Standard Library – A tutorial and reference”.

Initialize by using standard input:

//read all integer elements of the deque from standard input
std::deque<int> c((std::istream_iterator<int>(std::cin)),
(std::istream_iterator<int>()));

Don’t forget the extra parentheses around the initializer arguments
here. Otherwise, this expression does something very different and you
probably will get some strange warnings or errors in following
statements. Consider writing the statement without extra parentheses:

std::deque<int> c(std::istream_iterator<int>(std::cin),
std::istream_iterator<int>());

In this case, c declares a function with a return type that is
deque. Its first parameter is of type istream_iterator with
the name cin, and its second unnamed parameter is of type “function
taking no arguments returning istream_iterator.” This construct
is valid syntactically as either a declaration or an expression. So,
according to language rules, it is treated as a declaration. The extra
parentheses force the initializer not to match the syntax of a
declaration.

I can see why the one with extra parentheses is not considered a function declaration, but
I can’t see what would make the one without into a function declaration though? For it has parentheses around (std::cin), and as far as I know variables may not have names with parentheses?

Am I missing something?

  • 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-28T04:31:48+00:00Added an answer on May 28, 2026 at 4:31 am

    The tutorial you read is wrong. This:

    std::deque<int> c(std::istream_iterator<int>(std::cin), std::istream_iterator<int>());
    

    Can’t be parsed as a function declaration because std::cin can’t be a name of a parameter. If you remove the std qualifier though:

    std::deque<int> c(std::istream_iterator<int>(cin), std::istream_iterator<int>());
    

    then you get a function declaration.

    […] and as far as I know variables may not have names with parentheses?

    The parentheses aren’t part of the name. You can just put them there, how many you like:

    int ((((((a)))))) = 12345; // valid code!
    a++; // the variable is named 'a'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My next project is going to be using Windows Communication Foundation to host Managed
I've written a simple library file with a function for reading lines from a
I´m studing the code of OpenCV, and I came across the next few lines:
Over the next few months, we need to consider the best technology/technique for periodically
One of my goals over the next few months is to get familiar with
My site will be down for next few days. Is there any way to
I am new to asp and have a deadline in the next few days.
I have to interview some C++ candidates over the next few weeks and as
This is an extension / next step of this question I asked a few
I'm trying to read a (small-ish) file in chunks of a few lines at

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.