Open dareg opened 7 years ago
I think these kind of literals can be highlighted more generally. h
or ms
or s
or things are just a library implementation, not a language feature. We can define our original literals as below.
http://en.cppreference.com/w/cpp/language/user_literal
e.g.
int main() {
1.2_w; // calls operator "" _w(1.2L)
u"one"_w; // calls operator "" _w(u"one", 3)
12_w; // calls operator "" _w("12")
"two"_w; // error: no applicable literal operator
}
If we determine to define the chrono literals, we also need to define highlights for user defined literals. If not, IMO, we should not highlight literals defined in standard library also for consistency.
The point looks that we should highlight identifiers defined in standard library or not. Currently syntax/cpp.vim highlights no identifier defined in standard library as long as I know.
From my point of view, the chrono literals were just «enhanced numbers», that's why I have proposed to highlight them in the same color than the numbers. But I can understand that my view is too specific and not enough global.
yeah I understand that standard user-defined literals are near the language core feature and it looks better if they are highlighted as well as builtin literals such as 12ll
, 3.14f
. This looks tradeoff between persistency (highlights only core features) and usability (standard user-defined literals should be handled as well as builtin ones) for me. I want to leave this decision to @mattn.
Allow the duration to be highlighted as the numbers.
See this link for more informations on chrono literals: http://en.cppreference.com/w/cpp/chrono/duration