c++ - VS 2013 - IntelliSense reporting false positives? -


i'm working on c++ project where, among other things, have interface few pure virtual methods. problem arises when try implement interface - intellisense doesn't seem agree derived class's method declaration. example of such method:

// dll_export -> #define dll_export __declspec(dllexport) // iplayer dll_export virtual const grid& getgrid() const = 0; 

declaration in 1 of derived classes:

// human : iplayer dll_export const grid& iplayer::getgrid() const; 

the error keeps nagging me - "intellisense: declaration must correspond pure virtual member function in indicated base class". code compiles without errors , runs fine, of "problematic" methods jobs expected during run time. worth mentioning error disappears if remove iplayer:: scope qualifier in derived class. wanted keep there readability reasons. also, not proficient in c++ there wrong example i've provided.

minimized example:

struct c { virtual void f() = 0; };  struct d : c { void c::f() { } }; 

this doesn't compile in version of g++ or clang tested. intellisense in vs2013 uses edg frontend, , quote jonathan wakely, "if gcc, clang , edg agree , msvc disagrees means msvc wrong."

to make things more interesting, relevant paragraphs in standard changed between c++11 , c++14.

in c++11, flat-out illegal (n3337 §8.3 [dcl.meaning]/p1):

a declarator-id shall not qualified except definition of member function (9.3) or static data member (9.4) outside of class, definition or explicit instantiation of function or variable member of namespace outside of namespace, or definition of explicit specialization outside of namespace, or declaration of friend function member of class or namespace (11.3).

this sentence removed in c++14 result of cwg issue 482. proposed resolution issue has following note:

[drafting note: omission of “outside of class” here not give permission redeclaration of class members; still prohibited 9.2 [class.mem] paragraph 1. removal of enumeration of kinds of declarations in qualified-id can appear allow typedef declaration use qualified-id, not permitted before; if undesirable, prohibition can reinstated here.]

in c++14, applicable rule in §8.3 [dcl.meaning]/p1 (quoting n3936):

when declarator-id qualified, declaration shall refer declared member of class or namespace qualifier refers (or, in case of namespace, of element of inline namespace set of namespace (7.3.1)) or specialization thereof; member shall not merely have been introduced using-declaration in scope of class or namespace nominated nested-name-specifier of declarator-id.

the relevant part of §9.2 [class.mem]/p1 is:

except when used declare friends (11.3) or introduce name of member of base class derived class (7.3.3), member-declarations declare members of class, , each such member-declaration shall declare @ least 1 member name of class. member shall not declared twice in member-specification, except nested class or member class template can declared , later defined, , except enumeration can introduced opaque-enum-declaration , later redeclared enum-specifier.

since using-declaration "to introduce member of base class derived class" made explicit exception, appears base class members not considered members purposes of rule "member-declarations declare members of class, , each such member-declaration shall declare @ least 1 member name of class". if so, follows using qualified-id void c::f() { } in member-declaration not allowed in c++14, since qualified-id refers member of c, not member of d.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -