How can I convince emacs C++ mode than my less than isn't a template parameter? -


this problem has annoyed me years, , i'm wondering if has had solution. problem in c++ mode, seems emacs cant decide if < operator "less than" or "begin template parameters", messes auto-indent feature. consider this:

bool foo() {   return x < y &&              y < z; } 

that y way on right , if run c-set-offset (with c-c c-o) on line y < z, tells me current line offset template-args-cont. worst part code below this, including other functions, have totally screwed tabbing. manually space beginning of next function.

edit: confirm, following code indents correctly:

bool foo() {   return x == y &&     y == z; } 

edit 2: have custom style , offset stuff, starting emacs -q ignore .emacs file shows same problem. i'm using version:

gnu emacs 24.1.1 (x86_64-apple-darwin, ns apple-appkit-1038.36)  of 2012-06-10 on bob.porkrind.org 

on mac os x 10.8 i'm sure i've seen same problem on ubuntu, i'd have go double check versions.

has found solution this? corey discovered adding parens (x < y) workaround.

this looks more c++ issue of cc-mode. latter use smarter heuristics handle simpler issues, yours, in general less-than/template-open conflict hard solve without knowing if x template.

consider following code:

#include <iostream> using std::cout;  #ifdef template template <int i> int x(int arg) {   return + arg; } #else int x = -1; #endif  int main(int argc, char** argv) {   const int y = 0;    int foo = 1, bar = 2;    cout << (x < y && 10 > (foo + bar)) << '\n';   return 0; } 

it prints 3 if #define template source , 1 otherwise, , should break cout << ... line @ &&-op there's no way figure out proper indentation unless know exact build environment file.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -