Thread: how can implement a template class like this

  1. #16
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    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をこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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
    838
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

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