public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* vector instantiation
@ 2003-04-18 20:06 Andrey R. Urazov
  2003-04-19  8:44 ` Alex Vinokur
  2003-04-19 15:12 ` Jaap Haitsma
  0 siblings, 2 replies; 7+ messages in thread
From: Andrey R. Urazov @ 2003-04-18 20:06 UTC (permalink / raw)
  To: gcc-help

Hello,

Concerning the problem of instantiation of STL vector with the template
parameter size of array. Sorry, but I forgot to include the program code
in my posting. Here it is:

#include <vector>

using namespace std;

int main()
{
    vector<size_t[4]> v(10);

    return 0;
}




And compiling this with gcc-3.2.2 I get:

/usr/include/c++/3.2/bits/stl_vector.h: Dans constructor «
std::vector<_Tp,
   _Alloc>::vector(unsigned int) [with _Tp = size_t[4], _Alloc =
   std::allocator<size_t[4]>] »:
test.cpp:7:   instancié à partir d'ici
/usr/include/c++/3.2/bits/stl_vector.h:342: ISO C++ interdit le
transtypage
   vers un type tableau « size_t[4] »


P.S. Just in case, please CC me since I'm not on the mailing list. Thank
you.

Best regards,
	Andrey Urazov.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: vector instantiation
  2003-04-18 20:06 vector instantiation Andrey R. Urazov
@ 2003-04-19  8:44 ` Alex Vinokur
  2003-04-19 15:12 ` Jaap Haitsma
  1 sibling, 0 replies; 7+ messages in thread
From: Alex Vinokur @ 2003-04-19  8:44 UTC (permalink / raw)
  To: gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]


"Andrey R. Urazov" <coola@ngs.ru> wrote in message news:1050685291.981.5.camel@r-a117-bur...
Hello,

> Concerning the problem of instantiation of STL vector with the template
> parameter size of array. Sorry, but I forgot to include the program code
> in my posting. Here it is:
>
> #include <vector>
>
> using namespace std;
>
> int main()
> {
>     vector<size_t[4]> v(10);
      vector<char> v1(10), v2(20);
      vector<int>  v3(10), v4(20), v3 (123);
>
>     return 0;
> }
>
>
>
>
> And compiling this with gcc-3.2.2 I get:
>
> /usr/include/c++/3.2/bits/stl_vector.h: Dans constructor «
> std::vector<_Tp,
>    _Alloc>::vector(unsigned int) [with _Tp = size_t[4], _Alloc =
>    std::allocator<size_t[4]>] »:
> test.cpp:7:   instancié à partir d'ici
> /usr/include/c++/3.2/bits/stl_vector.h:342: ISO C++ interdit le
> transtypage
>    vers un type tableau « size_t[4] »
>
>
> P.S. Just in case, please CC me since I'm not on the mailing list. Thank
> you.
>
> Best regards,
> Andrey Urazov.
>
>

   =================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://www.simtel.net/pub/oth/19088.html
   =================================



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: vector instantiation
  2003-04-18 20:06 vector instantiation Andrey R. Urazov
  2003-04-19  8:44 ` Alex Vinokur
@ 2003-04-19 15:12 ` Jaap Haitsma
  2003-04-21  8:11   ` Andrey R. Urazov
  1 sibling, 1 reply; 7+ messages in thread
From: Jaap Haitsma @ 2003-04-19 15:12 UTC (permalink / raw)
  To: Andrey R. Urazov, gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1229 bytes --]

Hi Andrey,

I'm not sure if it is allowed to put arrays as a
parameter of the template. Why don't you make a class
or a struct which contains this array of 4 size_t's

Jaap 
--- "Andrey R. Urazov" <coola@ngs.ru> wrote:
> Hello,
> 
> Concerning the problem of instantiation of STL
> vector with the template
> parameter size of array. Sorry, but I forgot to
> include the program code
> in my posting. Here it is:
> 
> #include <vector>
> 
> using namespace std;
> 
> int main()
> {
>     vector<size_t[4]> v(10);
> 
>     return 0;
> }
> 
> 
> 
> 
> And compiling this with gcc-3.2.2 I get:
> 
> /usr/include/c++/3.2/bits/stl_vector.h: Dans
> constructor «
> std::vector<_Tp,
>    _Alloc>::vector(unsigned int) [with _Tp =
> size_t[4], _Alloc =
>    std::allocator<size_t[4]>] »:
> test.cpp:7:   instancié à partir d'ici
> /usr/include/c++/3.2/bits/stl_vector.h:342: ISO C++
> interdit le
> transtypage
>    vers un type tableau « size_t[4] »
> 
> 
> P.S. Just in case, please CC me since I'm not on the
> mailing list. Thank
> you.
> 
> Best regards,
> 	Andrey Urazov.
> 


__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: vector instantiation
  2003-04-19 15:12 ` Jaap Haitsma
@ 2003-04-21  8:11   ` Andrey R. Urazov
  2003-04-21 16:24     ` drkm
  0 siblings, 1 reply; 7+ messages in thread
From: Andrey R. Urazov @ 2003-04-21  8:11 UTC (permalink / raw)
  To: Jaap Haitsma, gcc-help

Le sam 19/04/2003 à 20:10, Jaap Haitsma a écrit :
> Hi Andrey,
> 
> I'm not sure if it is allowed to put arrays as a
> parameter of the template. Why don't you make a class
> or a struct which contains this array of 4 size_t's
Because an array of 4 elements is just a particular case. In general
there are n elements and n is known at compile time.

Best regards,
    Andrey Urazov

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: vector instantiation
  2003-04-21  8:11   ` Andrey R. Urazov
@ 2003-04-21 16:24     ` drkm
  0 siblings, 0 replies; 7+ messages in thread
From: drkm @ 2003-04-21 16:24 UTC (permalink / raw)
  To: gcc-help

 --- "Andrey R. Urazov" <coola@ngs.ru> a écrit : 

> > I'm not sure if it is allowed to put arrays as a
> > parameter of the template. Why don't you make a class
> > or a struct which contains this array of 4 size_t's

> Because an array of 4 elements is just a particular case. In general
> there are n elements and n is known at compile time.

  What do you think about

    template < typename T , size_t N >
    struct MyWrapper
    {
      T     myArray[ N ] ;
    } ;

    std::vector< MyWrapper< size_t , 4 > >
                                    the_array ;

?

  But why do you not want the following :

    std::vector< std::vector< size_t > >
                                    the_array ;

or

    std::vector< boost::array< size_t , 4 > >
                                    the_array ;

?

  Best regards,

--drkm


___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: vector instantiation
  2003-04-17  8:47 Andrey R. Urazov
@ 2003-04-17 11:55 ` Alex Vinokur
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Vinokur @ 2003-04-17 11:55 UTC (permalink / raw)
  To: gcc-help


"Andrey R. Urazov" <coola@ngs.ru> wrote in message news:1050558071.1020.15.camel@r-a117-bur...
> Hello,
>
> I tried to declare vector with the template parameter of array and,
> unfortunately, the compilation failed with the following error message
> (I'm using gcc-3.2.2):
>
> /usr/include/c++/3.2/bits/stl_vector.h: In constructor `std::vector<_Tp,
>    _Alloc>::vector(unsigned int) [with _Tp = size_t[4], _Alloc =
>    std::allocator<size_t[4]>]':
> test.cpp:7:   instantiated from here
> /usr/include/c++/3.2/bits/stl_vector.h:342: ISO C++ forbids casting to
> an array
>    type `size_t[4]'
>

Could you send your code to news:gmane.comp.gcc.help ?

> I think this is incorrect behavior. But, of course, I may be wrong. Any
> ideas? Is permitted to declare STL containers with the elements of
> arrays in the C++ standard?
>
> Best regards,
> Andrey Urazov.
>
>

   =================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://www.simtel.net/pub/oth/19088.html
   =================================



^ permalink raw reply	[flat|nested] 7+ messages in thread

* vector instantiation
@ 2003-04-17  8:47 Andrey R. Urazov
  2003-04-17 11:55 ` Alex Vinokur
  0 siblings, 1 reply; 7+ messages in thread
From: Andrey R. Urazov @ 2003-04-17  8:47 UTC (permalink / raw)
  To: gcc-help

Hello,

I tried to declare vector with the template parameter of array and,
unfortunately, the compilation failed with the following error message
(I'm using gcc-3.2.2):

/usr/include/c++/3.2/bits/stl_vector.h: In constructor `std::vector<_Tp,
   _Alloc>::vector(unsigned int) [with _Tp = size_t[4], _Alloc =
   std::allocator<size_t[4]>]':
test.cpp:7:   instantiated from here
/usr/include/c++/3.2/bits/stl_vector.h:342: ISO C++ forbids casting to
an array
   type `size_t[4]'

I think this is incorrect behavior. But, of course, I may be wrong. Any
ideas? Is permitted to declare STL containers with the elements of
arrays in the C++ standard?

Best regards,
	Andrey Urazov.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-04-21 16:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-18 20:06 vector instantiation Andrey R. Urazov
2003-04-19  8:44 ` Alex Vinokur
2003-04-19 15:12 ` Jaap Haitsma
2003-04-21  8:11   ` Andrey R. Urazov
2003-04-21 16:24     ` drkm
  -- strict thread matches above, loose matches on Subject: below --
2003-04-17  8:47 Andrey R. Urazov
2003-04-17 11:55 ` Alex Vinokur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).