I just updated my arch linux system to the latest which includes gcc 7.1.1. Trying to build this:
#include <functional>
int main(int argc, char** argv) {
return 1;
}
using the command
clang++ main.cpp -std=c++1z
results in the error:
In file included from main.cpp:1:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/functional:60:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/unordered_map:47:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/hashtable.h:37:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/node_handle.h:39:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:27: error: use of class template 'optional'
requires template arguments
template <typename _Tp> optional(_Tp) -> optional<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:451:11: note: template is declared here
class optional
^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:40: error: expected ';' at end of declaration
template <typename _Tp> optional(_Tp) -> optional<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:41: error: cannot use arrow operator on a type
template <typename _Tp> optional(_Tp) -> optional<_Tp>;
Is this an error on my part, arch linux, or clang?
Update: (forgot to add versions)
Little late but I would like to sum it up.
This:
template <typename _Tp> optional(_Tp) -> optional<_Tp>;
is the example of deduction guides. Here you can find nice explanation of this language feature.
New version of libstdc++ uses it in its implementation when -std=c++17 or c++1z flag is in use. Unfortunately Clang does not support this feature yet. Clang C++1z status page reports it as available only on SVN.
You can find bug report for Arch Linux here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With