Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
no-fail swap for char []'s
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Dennis Jones, post: 3407292"] A couple of changes got it to work: template<unsigned s> void strswap(char (a1)[s], char (a2)[s]) // removed the '&'s { for (unsigned i = s; i-- > 0; ) std::swap(a1[i], a2[i]); } class Test { public: char str[10]; void swap( Test &rhs ) { strswap<10>( str, rhs.str ); // added the "<10>" } }; So, apparently, the compiler *cannot* deduce 's' at compile-time (or I'm still doing something wrong). - Dennis[/i][/i][/s][/s] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
no-fail swap for char []'s
Top