Wednesday, December 4, 2013

Re: How would a vim guru type this c++ snippet?

Hello,

> Regarding the change from test1.cpp -> test2.cpp, will you please do
> one of the following:

First of all.
You know that in your particular case, you don't need nor you don't want any of these ? (because the default copy-constructor and assignment operator will be more efficient)
Well. The default constructor is almost acceptable, but I tend to prefer init-constructor.

Otherwise, with lh-cpp (see my sig), expecting you have an up-to-date ctag database, you can put the cursor within your class definition, and type:
:Constructor
It will open a dialog buffer where you'll have to select (by hitting <space>) the attributes you want in the init-constructor. Then hit <enter>, et voilà.

BTW, I've a little issue with your naming policies. The default settings will automatically convert m_Foo to foo (regarding parameters names), but not mFoo. I have to find out how to fix strip_re (defined with:
b:cpp_naming_strip_re='^\%(get\|set\|[mgsp]_\|_\+\)\=\(.\{-}\)\%(_\=\)$' )
So that substitute('mFoo', {b:cpp_naming_}strip_re, '\l\1') will also work correctly
(you can play with :DOX to automatically generate the doxygen comment associated to the new function)

Any way.

At that time, I've haven't written (yet) neiher a wizard for a swap() function, nor for the copy-constructor. It should be easy to do on the same model of the one of :Constructor
Regarding the assignment operator, lh-cpp (through mu-template) provide several snippets:
- copy-and-swap
- assignment-operator -- you may want to use :MOVETOIMPL to move the inlined assignment operator to the .cpp file
- copy-constructor
- destructor

HTH,
(more latter I guess)
--
Luc Hermitte
http://lh-vim.googlecode.com/

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: