how can implement a template class like this

This is a discussion on how can implement a template class like this within the C++ Programming forums, part of the General Programming Boards category; please demonstrate how to execute std::copy of a multidimensional array with a simple 1-liner. i attempted it briefly and failed....

  1. #16
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    please demonstrate how to execute std::copy of a multidimensional array with a simple 1-liner. i attempted it briefly and failed.

  2. #17
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,545
    I admit it's a bit of a hack, but since we ARE using C arrays (damn, I hate it that support for initializer lists do not exist in VC++ >_<), this should be fine.
    Code:
    std::copy((T*)data, (T*)data + (Rows * Columns), mem);
    Use reinterpret_cast to really pedantic.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    well, that works just fine. i swore i tried casting to T* just like that and i got a compile error in xutility. clearly i made an error somewhere.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 01-30-2011, 03:28 PM
  2. Replies: 27
    Last Post: 08-21-2008, 11:38 AM
  3. Replies: 9
    Last Post: 11-12-2007, 02:29 PM
  4. Replies: 4
    Last Post: 11-01-2006, 01:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21