Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Improvements for "Implement Virtual Methods..."
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Vertexwahn
Senior Member

35 Posts

Posted - Feb 08 2014 :  3:19:37 PM  Show Profile  Reply with Quote

class Base
{
public:
  virtual void foo() = 0;
};


"Implement Virtual Methods..." generates this code:


class Derived
{
  virtual void foo()
  {
    throw std::exception("The method or operation is not implemented.");
  }
};


From http://stackoverflow.com/questions/1569726/difference-stdruntime-error-vs-stdexception:
"std::exception is the class whose only purpose is to serve as the base class in the exception hierarchy. It has no other uses. In other words, conceptually it is an abstract class"

Throw std::runtime_error instead of std::exception!

Otherwise gcc generates errors like "std::exception" is abstract...

Add a checkbox that adds the override keyword to an overwritten virtual method

Example:

class Derived2
{
  virtual void foo() override
  {
    throw std::runtime_error("The method or operation is not implemented.");
  }
};

Dusan
Whole Tomato Software

Slovakia
177 Posts

Posted - Feb 10 2014 :  03:48:42 AM  Show Profile  Reply with Quote
quote:
Originally posted by Vertexwahn
Example:

class Derived2
{
  virtual void foo() override
  {
    throw std::runtime_error("The method or operation is not implemented.");
  }
};




You can change the behavior of refactoring by editing VA Snippets:
http://docs.wholetomato.com/default.asp?W258

You may want to use refactoring reserved strings.
http://docs.wholetomato.com/default.asp?W262

HTH

Edited by - Dusan on Feb 10 2014 03:49:31 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Feb 11 2014 :  4:25:40 PM  Show Profile  Reply with Quote
The generated function body has been fixed in VA 1940 and above, the new default function body for C++ is now:

throw std::logic_error("The method or operation is not implemented.");

but we are not replacing your existing VA Snippet, so for now you will need to edit the VA Snippet "Refactor Create From Usage Method Body" as Dusan says.


To automatically add the override keyword simply set a simple registry value, as explained here:

https://wholetomato.fogbugz.com/default.asp?W346

zen is the art of being at one with the two'ness

Edited by - feline on Feb 11 2014 4:27:09 PM
Go to Top of Page

jschroedl
Tomato Guru

USA
104 Posts

Posted - Apr 15 2014 :  12:37:23 PM  Show Profile  Reply with Quote
Wow, pretty obscure. I added this but feel it should not require a regedit to turn this on.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Apr 15 2014 :  9:24:35 PM  Show Profile  Reply with Quote
To try and keep our options dialog fairly manageable, some less frequently used settings are exposed via registry keys. We keep an eye on this, and settings that get a lot of interest tend to be moved into the options dialog over time. This is not a setting that a lot of people ask about. Not the perfect way of judging its interest level, but its a start.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000