Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Implement Interface does not work for local class

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
andre.horst Posted - Jun 17 2013 : 01:31:16 AM
Latest VAX, VC2010, Win7.

class CInterface
{
public:
	virtual void Foo() = 0 ;
} ;

void f()
{
	class CImpl : public CInter[PLACE_CURSOR_HERE]face 
	{
	public:
	} ;
}


Place cursor on CInterface and "Implement Interface" is not available in VAX pop up menu.
8   L A T E S T    R E P L I E S    (Newest First)
sean Posted - Feb 26 2014 : 10:40:37 AM
case=74977 is fixed in build 2029
feline Posted - Jun 24 2013 : 2:02:49 PM
I know struct and class are virtually identical in C++, this has come up before, occasionally, when people have reported bugs deriving a struct, since it has been known to confuse our parser. Its very rare to see this done though, which is why I asked

I did not know that some things can only be done with struct's though, that's interesting, and does help to explain why you used struct here, in addition to producing a challenging test case

Thank you for the example, I have added this to the bug report, so we will know to keep an eye on code like this.
andre.horst Posted - Jun 21 2013 : 02:51:58 AM
In C++ class and struct are nearly the same, but in a struct you normaly have no ctor, members are public by default, different vtable, and so on. Some tricky template things can only be done with structs and not with classes (f.e. template typedefs, do not know why ). I used struct just to have a unexpected keyword for a "class" in this test-case and it seems, that I choosed right
feline Posted - Jun 20 2013 : 11:36:10 AM
Code being confidential is normal, and expected. Thank you for this, that's definitely a more complex example than any I was likely to come up with!

Its taken a little bit of wrapping my head around. Just to make sure I understand correctly, you would be looking to trigger Implement Interface on the "struct s" created inside Foo() ?

Any reason for making this a struct? I know you can derive a struct from something else, but it is very rarely done in my experience.
andre.horst Posted - Jun 19 2013 : 02:04:10 AM
Sorry, most examples are to complex and have too many dependencies to other classes and the code is confidential. But here is a example that should catch most test cases (works only at VC2010SP1+). To answer your question how often I use such constructs: not very often

class __declspec( novtable ) CIInitable
{
public:
	virtual void Init( void ) = 0 ;
} ;

template< class FUNC >
typename FUNC::result_type FooBar( FUNC func, const typename FUNC::first_argument_type p )
{
	if( true == std::is_base_of< CIInitable, FUNC >::value )
	{
		func.Init() ;
	}
	return func( p, 4711 ) ;
}

template< class P >
P Foo( const P p )
{
	struct s : public std::binary_function< P, P, P >, public virtual CIInitable
	{
		result_type operator()( first_argument_type x, second_argument_type y )
		{
			return x + y ;
		}

		virtual void Init( void )
		{
			// Do some funny stuff
		}
	} ;
	s  f ;
	return FooBar( f, p ) ;
}

int result = Foo( 42 ) ;
feline Posted - Jun 18 2013 : 7:09:22 PM
Ah, thank you for the explanation Do you have an example or two of real usage that you would be able to post, that I can use to make more realistic test cases with? I will certainly make sure to run some more complex tests on this when I get to it, its also good to know we are testing the sort of thing you are doing as well.
andre.horst Posted - Jun 18 2013 : 12:45:26 AM
I use such code to create template functions that uses for example a functor class that should not be visible outside the function, thus this is a bit simplified example. So expand the real testcases with template functions and inner classes
feline Posted - Jun 17 2013 : 3:12:16 PM
I am seeing the same effect here. Thank you for the clear description.

case=74977

This surprised me, I was not aware you could declare a class inside a function, but thinking about it, it does make sense, since this is just another way of restricting the scope of the new class. Plus it compiles, always a good test

Do you have a lot of code that does this? Or is this only used a few times?

© 2021 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000