Author Topic: Strange formatting in C++11 Constructor Initialization list  (Read 1573 times)

acarlow

  • Junior Community Member
  • Posts: 3
  • Hero Points: 1
Strange formatting in C++11 Constructor Initialization list
« on: February 27, 2014, 06:52:55 am »
Notice, that the closing brace of the initialization list goes on the next line:

Code: [Select]
Student::Student(string first, string middle, string last, string id)
    : student{new Student_impl{first, middle, last, id}
}
{
   std::cerr << "Student ctor\n";
}

Also, I see no way to configure the formatting to fix this or to adjust the spacing before the braces in the initializer list.  I'd like to get something like this:

Code: [Select]
Student::Student(string first, string middle, string last, string id)
    : student {new Student_impl {first, middle, last, id}}
{
   std::cerr << "Student ctor\n";
}

Move Constructors are even different from other constructors:
Code: [Select]
Student::Student(Student&& src)noexcept
: student{new Student_impl{first, middle, last, id}
}
{
    std::cerr << "Student move ctor\n";
}

Notice how the initialization list line is not indented the way the regular constructor is.  Also, I don't see how to adjust the spacing of the "noexcept" specification.

Any ideas?
« Last Edit: February 27, 2014, 10:07:01 pm by acarlow »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 986
  • Hero Points: 78
Re: Strange formatting in C++11 Constructor Initialization list
« Reply #1 on: February 27, 2014, 02:55:35 pm »
The brace placement and and spacing differences with the move constructors appears to be a bug, not intentional.  I'll take a look at those later today.

For control of the spacing, we might want to add different settings for the brace initializers - currently
Code: [Select]
student{Student_Impl{a, b, c, d}} is treated as nested function calls, so the settings under Spacing -> Expressions -> Function/Method calls handle that case. Even then, something is wrong, because it's only seeming to effect the inner initializer.  I'll have to look at that as well.

acarlow

  • Junior Community Member
  • Posts: 3
  • Hero Points: 1
Re: Strange formatting in C++11 Constructor Initialization list
« Reply #2 on: February 27, 2014, 10:09:22 pm »
I'm glad to see it wasn't just user error and that you are working on it.  Also, I clarified my other post regarding struct/POD uniform initialization and auto-complete.  Hopefully that is something else that can be looked into?

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 986
  • Hero Points: 78
Re: Strange formatting in C++11 Constructor Initialization list
« Reply #3 on: February 28, 2014, 04:54:10 pm »
Fixed the blatant formatting problems, but they were not hot fixable, so they'll be in the next release.

I haven't decided how to handle the new spacing settings yet, but I'd like to get those in the next release as well.

Re: the other thread, I did see it, but didn't get any further than verifying I see the same behavior.  I'll probably get to take a deeper look at it later this afternoon.