-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for the latest C++ standard #596
Conversation
Why? |
C++98: int arr [] = {1, 2, 3, 4};
vector<int> vec (arr, arr + 4);
for (vector<int>::iterator vit = vec.begin(); vit != vec.end(); ++vit) cout << *vit << endl; C++11: vector<int> vec {1, 2, 3, 4};
for (auto val : vec) cout << val << endl; |
C++98: int sum(int count, ...)
{
va_list vl;
va_start(vl, count);
int sum = 0;
for (int i = 0; i < count; ++i)
{
sum += va_arg(vl, int);
}
va_end(vl);
return sum;
} C++11: int sum(int i)
{
return i;
}
template <typename... VA>
int sum(int i, VA ...va)
{
return i + sum(va...);
} |
C++98: class funky
{
public:
bool operator() (int i)
{
return i < 4;
}
};
cout << count_if(vec.begin(), vec.end(), funky()) << endl; C++11: cout << count_if(vec.begin(), vec.end(), [](int i){return i < 4;}) << endl; |
C++11: double operator"" _bin(const char* lit)
{
if (*lit == '0') return 0;
double res = 0;
while (*lit and *lit != '.') res *= 2, res += *lit++ - '0';
if (*lit) ++lit;
else return res;
double di = 1;
while (*lit) di *= 2, res += (*lit++ - '0')/di;
return res;
}
. . .
cout << -11.1_bin << endl; C++98: |
Good! I only asked "why?" and got you to post the entire C++ 11 specification. |
*munch I haven't even mentioned the new smart pointer, timing, threading, or regular expression libraries (though some of those (regexes) are still not supported by GCC) |
"(though some of those (regexes) are still not supported by GCC)" Thats the reason why we wont use it. |
hdastwb, thanks to this pull request, we know specifically why C++11 shouldn't be used. Although it does marginally increase the expressiveness of C++, we would never benefit from that. The code snippets you pasted are pretty crazy, all examples of things that would never be allowed in Minetest's codebase. Code needs to be really simple and stupid, not relying on such high-level features. That last example with the _bin operator is especially insane, and brings no benefit at all over simply passing that literal to a function called bin(). Lots of potential for obsfucation, though. |
With all due respect why has this been closed within 24 hours.... why has it not been left for discussion. @kwolekr listed his reasons why it shouldn't be merged but what if other users have ideas on how to combat that. I understand your reasons, i just don't understand why this wasn't given a chance to be discussed further. heck only 2 core-developers commented on it and one of them barely said much. To note I'm not a C++ developer. but I have a basic understanding due to developing in other languages. All im saying is why are we knocking it before anyones had chance to talk about it properly. I awaits to have my head bitten off and raged at :/ |
personally i agree with C++11 if windows 7 and more + supports it (windows XP isn't supported by M$) Ubuntu was okay, we must look at debian to see if it's supported. On archlinux it's good, on recent Fedora and redhat too, on FreeBSD it's good. What we need to use in c++11, i think: std::regex |
I'm not convinced that we need to switch from jthread to std::thread/std::mutex. For example, on Windows std::mutex seems to be a whole lot slower than critical sections (which is what JMutex uses): http://stackoverflow.com/a/24470878 |
I have said it before and I'll say it again: a lot of people still use LTS operating systems that do not support C++11. These are people who run servers. If we discount those people then the audience is decreased. My VPS does not (fully) support C++11 and I know at least two other people who run (popular or semi-popular) servers that are in the same boat. To switch to C++11 would require a compelling reason, IMO. This is not compelling enough. |
We need to wait 2 years more :( |
Maybe not 2 years. But this PR was not and is not worth the effort and disruption (IMO) |
No, there is a currently supported LTS version of Ubuntu that does not support c++11 (I happen to use it and as a core dev I'd like to be able to compile Minetest ;-)) |
Thus, people can use some of the new features listed here:
http://www.stroustrup.com/C++11FAQ.html
or here:
http://en.wikipedia.org/wiki/C%2B%2B11
with newer compilers