Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 BUG: Incorrect hint in specialized functions

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
thedmd Posted - Aug 05 2010 : 6:31:47 PM
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;
}
2   L A T E S T    R E P L I E S    (Newest First)
thedmd Posted - Aug 08 2010 : 03:32:51 AM
Thank you for the hint. I didn't thought about that.
accord Posted - Aug 06 2010 : 5:26:15 PM
I am seeing the same effect here. Thank you for the clear description and the full source. I have put in a bug report for this:

case=48428

It seems VA does not like the namespace qualifier. When I remove it, everything seems great:



So for now, "using namespace" (i.e. using namespace EState) might be a suitable workaround.

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