Hello, I'm testing VA in my development machine. Recently I found that VA do not handle correctly specialized template functions implemented outside of class. Bellow are the screens from editor view and outline view. As you can see marked statement is underlined incorrectly. Also outline view contain an error.
Source code which reveal described behavior is included at the bottom of this post.
VA version: 10.6.1823.0


# include <iostream>
using namespace std;
namespace EState
{
enum type_t
{
FIRST,
SECOND,
THIRD
};
}
class THint
{
public:
void bar()
{
}
};
class TMachine
{
public:
TMachine();
~TMachine();
void SetState(EState::type_t state);
EState::type_t GetState() const;
void UpdateState();
private:
template <EState::type_t STATE> void Enter() {}
template <EState::type_t STATE> void Leave() {}
template <EState::type_t STATE> void Update() {}
template <>
void Enter<EState::FIRST>();
template <>
void Leave<EState::FIRST>();
template <>
void Update<EState::SECOND>();
void EnterState(EState::type_t state);
void LeaveState(EState::type_t state);
void UpdateState(EState::type_t state);
THint mHint;
EState::type_t mState;
};
TMachine::TMachine()
{
mState = EState::FIRST;
EnterState(mState);
}
TMachine::~TMachine()
{
LeaveState(mState);
}
void TMachine::SetState(EState::type_t state)
{
LeaveState(mState);
mState = state;
EnterState(state);
}
EState::type_t TMachine::GetState() const
{
return mState;
}
void TMachine::UpdateState()
{
UpdateState(mState);
}
template <>
void TMachine::Enter<EState::FIRST>()
{
cout << "Enter \\"first\\" EState." << endl;
// BUG: type 'this' and wait for hint, you will see FIRST, SECOND and THIRD
// BUG: incorrect underline
this->mHint.bar();
// OK
mHint.bar();
}
template <>
void TMachine::Leave<EState::FIRST>()
{
cout << "Leave \\"first\\" EState." << endl;
// BUG: type 'this' and wait for hint, you will see FIRST, SECOND and THIRD
}
template <>
void TMachine::Update<EState::SECOND>()
{
cout << "Update \\"second\\" EState." << endl;
// BUG: type 'this' and wait for hint, you will see FIRST, SECOND and THIRD
}
void TMachine::EnterState(EState::type_t state)
{
if (state == EState::FIRST)
Enter<EState::FIRST>();
else if (state == EState::SECOND)
Enter<EState::SECOND>();
else if (state == EState::THIRD)
Enter<EState::THIRD>();
else
cerr << "Invalid state" << endl;
}
void TMachine::LeaveState(EState::type_t state)
{
if (state == EState::FIRST)
Leave<EState::FIRST>();
else if (state == EState::SECOND)
Leave<EState::SECOND>();
else if (state == EState::THIRD)
Leave<EState::THIRD>();
else
cerr << "Invalid state" << endl;
}
void TMachine::UpdateState(EState::type_t state)
{
if (state == EState::FIRST)
Update<EState::FIRST>();
else if (state == EState::SECOND)
Update<EState::SECOND>();
else if (state == EState::THIRD)
Update<EState::THIRD>();
else
cerr << "Invalid state" << endl;
}
int main()
{
TMachine obj;
obj.SetState(EState::SECOND);
obj.UpdateState();
obj.UpdateState();
obj.UpdateState();
obj.SetState(EState::THIRD);
obj.UpdateState();
obj.UpdateState();
obj.SetState(EState::FIRST);
obj.UpdateState();
return 0;
}