Logo
Explore Help
Sign In
feedc0de/qt-creator
1
0
Fork 0
You've already forked qt-creator
forked from qt-creator/qt-creator
Code Pull Requests Activity
Files
005ca71cac65b7c766d814b97b830e2af1c7aa53
qt-creator/tests/auto/cplusplus/cxx11/data/userDefinedLiterals.1.cpp

8 lines
187 B
C++
Raw Normal View History

C++: Basic support for C++11 user-defined literals 1. Extends lexer so digit or string can be followed by underscore '_' and alphanumeric defining literal. 2. Extends parser so it accepts operator"" _abc(...) user-defined literal definition. 3. Adds Token::Flags.userDefinedLiteral bool flag field representing if token carries user-defined literal. 4. Adds C++11 auto tests case with: 12_km, 0.5_Pa, 'c'_X, "abd"_L, u"xyz"_M 5. All optional suffix scanning methods now return boolean if the suffix was found. 6. Adds C++ Lexer tests for user-defined literals with C++11 feature enabled. This change however does not make QtCreator understand user-defined literal semantics, e.g. properly resolve type when applying custom literal operator. Change-Id: I30e62f025ec9fb11c39261985ea4d772b1a80949 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2014-11-02 14:42:23 +01:00
constexpr long double operator"" _inv(long double value) {
return 1.0 / value;
}
int main() {
auto foo = operator"" _inv(2.3);
return 12_km + 0.5_Pa + 'c'_X + "abd"_L + u"xyz"_M;
}
Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 56ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API