Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #14263

what is the default constructor for the POD type

From Stanley Rice <heconghui@gmail.com>
Newsgroups comp.lang.c++
Subject what is the default constructor for the POD type
Date 2012-02-18 22:33 -0800
Organization http://groups.google.com
Message-ID <380648.381.1329633206448.JavaMail.geo-discussion-forums@pbeo1> (permalink)

Show all headers | View raw


I want to know the *default constructor* for the POD type. Since STL 
implement some of the function based on the type of the paramter, fill_n 
for example, may have different implementation, one for the POD type, where 
no constructor will be called, and other for non-POD type. So I wrote the 
code:
    vector<int> vec(5);
and follow the debugger. Finlly, I come across a function:

template<typename _OutputIterator, typename _Size, typename _Tp>
  inline typename
  __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type
  __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value)
  {
    const _Tp __tmp = __value;
    for (; __n > 0; --__n, ++__first)
      *__first = __tmp;
    return __first;
  }

which is defined in stl_algobse.h. I print out the value of the parameter 
*__value* and the result is: 
    (const int &) @0xbffff338: 0
and the value of __tmp is: 0

I didn't initialize the __value, so I think the value of variable __value 
should be *random*, just like a normal variable definition without 
initializaion. But, here the value is always 0, Why?

Thanks.

Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

what is the default constructor for the POD type Stanley Rice <heconghui@gmail.com> - 2012-02-18 22:33 -0800
  Re: what is the default constructor for the POD type "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-02-19 07:48 +0100
  Re: what is the default constructor for the POD type Goran <goran.pusic@gmail.com> - 2012-02-19 09:20 -0800
    Re: what is the default constructor for the POD type Melissa <melis@a.com> - 2012-02-19 18:44 +0100
    Re: what is the default constructor for the POD type "Asger Joergensen" <Junk@Asger-P.dk> - 2012-02-19 18:29 +0000
    Re: what is the default constructor for the POD type "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-02-20 00:21 +0100

csiph-web