0

I'm currently trying to use a double chevron in a string for "<<" and ">>" to represent bit shifting. However, my program does not seem to recognize using double chevrons for any input. If I change it to any other string, it works perfectly.

derpleft will work, however "<<" will not work.

keywords_["derpleft"]  = keywords_["<<"] = make<BitShiftLeft>();
keywords_["derpright"] = keywords_[">>"] =  make<BitShiftRight>();

dictionary_type keywords_;

typedef std::map<string_type,Token::pointer_type>   dictionary_type;

typedef std::string string_type;
Benjamin Lindley
  • 101,917
  • 9
  • 204
  • 274
Vernah
  • 81
  • 1
  • 4
  • 11

2 Answers2

0

I just don't understand this statement:

keywords_["derpleft"]  = keywords_["<<"] = make<BitShiftLeft>();

It seems you want << and derpleft to point to (store) the value returned by make<BitShiftLeft> call. In that case, why not simply it as follows:

keywords_["derpleft"]  = make<BitShiftLeft>();
keywords_["<<"] =  make<BitShiftLeft>();

You may store the value of make call in some local variable (auto keyword preferred).

And most importantly, you did not mention what the problem is!

Ajay
  • 18,086
  • 12
  • 59
  • 105
  • It's *very* common usage to do `x = z = somefunction()` to set z and x to the output of somefunction(). Splitting that into two different calls with result in `somefunction()` being called twice (which you may not want to do) and can be harder to maintain. – Nik Bougalis Dec 08 '12 at 06:02
  • Yeah, I am aware of that! But it doesn't look good in the code posted above. `map::operator[]` will be called as LValue, then RValue, then LValue. I haven't tried, but how what about `keywords["<<"]` call - one call or two calls? – Ajay Dec 08 '12 at 06:07
0

I forgot to close this thread, but the issue was I did not set a boolean to true in one of my editor functions. It was simply a logic error that I created.

Vernah
  • 81
  • 1
  • 4
  • 11