c++17

linking std::experimental::filesystem with Xcode 9

孤街醉人 提交于 2019-11-30 05:07:44
问题 I am using std::experimental::filesystem with Xcode 9.0 beta. The compiler phase completes OK but the linker complains of undefined symbols: std::experimental::filesystem::v1::path::__filename() const std::experimental::filesystem::v1::path::__filename() const std::experimental::filesystem::v1::path::__stem() const std::experimental::filesystem::v1::__status(std::experimental::filesystem::v1::path const&, std::__1::error_code*) I am also using std::experimental::filesystem::canonical(), but

How to enable C++17 on Mac?

痴心易碎 提交于 2019-11-30 04:54:33
I am able to update gcc on Linux to get -std=c++17 but cannot do the same on Mac. Is there a version of Clang I can update to or some other alternative to get C++17 on my Mac? Please help. Thanks. On my 10.11 El Capitan, Xcode 7.3.1, clang has been updated to: Apple LLVM version 7.3.0 (clang-703.0.31) which is almost equivalent to llvm version 3.8. clang++ hasn't -std=c++17 option, but -std=c++1z , working well at present, though only supporting some features of C++1z. For gcc, you can install a very new one by: brew install gcc --HEAD which will install gcc-6.1 now, (2016.8). This gcc has

C++1z Coroutines a language feature?

北城余情 提交于 2019-11-30 04:47:58
问题 Why will coroutines (as of now in the newest drafts for C++1z) be implemented as a core language feature (fancy keywords and all) as opposed to a library extension? There already exist a couple of implementations for them (Boost.Coroutine, etc), some of which can be made platform independent, from what i have read. Why has the committee decided to bake it into the core language itself? I'm not saying they shouldn't but Bjarne Stroustrup himself mentioned in some talk (don't know which one any

Why do I have two destructor implementations in my assembly output? [duplicate]

穿精又带淫゛_ 提交于 2019-11-30 04:47:37
This question already has an answer here: GNU GCC (g++): Why does it generate multiple dtors? 2 answers And objdump of my .o file reveals that I have two different destructors for the same class. Why? Disassembly of section .text._ZN1AD0Ev: 0000000000000000 <_ZN1AD0Ev>: 0: 53 push %rbx 1: be 00 00 00 00 mov $0x0,%esi 6: 48 89 fb mov %rdi,%rbx 9: 48 c7 07 00 00 00 00 movq $0x0,(%rdi) 10: ba 2c 00 00 00 mov $0x2c,%edx 15: bf 00 00 00 00 mov $0x0,%edi 1a: e8 00 00 00 00 callq 1f <_ZN1AD0Ev+0x1f> 1f: 48 89 df mov %rbx,%rdi 22: be 08 00 00 00 mov $0x8,%esi 27: 5b pop %rbx 28: e9 00 00 00 00 jmpq 2d

Undefined behaviour in repeated use of prefix ++ operator

自古美人都是妖i 提交于 2019-11-30 04:42:00
I read this answer about undefined behaviour, where I saw following statement: ++++++i; // UB, parsed as (++(++(++i))) I don't think it is undefined behaviour. I have a doubt, Is it really UB in C++? If yes, then How? Also, I made program and compiled using g++ prog.cpp -Wall -Wextra -std=gnu++1z -pedantic command, it's working fine without any warning. It's give an expected output. #include <iostream> using namespace std; int main() { int i = 0; cout<<++++++i<<endl; } In C++03 it is undefined behavior. In C++11 it is not. There is no sequence point between the various pre-increments. If i was

Can non-type template parameters in c++17 be decltype(auto)?

半世苍凉 提交于 2019-11-30 04:41:35
I discovered that gcc and clang allow to use decltype(auto) in non-type template parameter type clause. E.g.: template <decltype(auto)> struct X {}; int foo ; int main() { X<(foo)> x; static_cast<void>(x); } [live demo gcc] [live demo clang] Is it standard compliant feature or is it some gnu extension? This is standard. First, for a non-type template parameter: [temp.param/4] A non-type template-parameter shall have one of the following (optionally cv-qualified) types: ... a type that contains a placeholder type . Where placeholder types have the following specified: [dcl.spec.auto/1] The auto

Can auto placeholder be used to deduce function result in non-type template parameter?

♀尐吖头ヾ 提交于 2019-11-30 03:50:34
问题 Consider simple example: template <auto(*X)()> struct Foo { decltype(X()) x; }; int bar(); int main() { static_cast<void>(Foo<bar>{}); } Both [gcc] and [clang] seem to accept the code. Is the code really c++17 compliant? If so is there some other rule that makes the following code ill formed? template <class T, auto(*X)(T)> struct Foo { decltype(X(0)) x; }; int bar(int); int main() { static_cast<void>(Foo<int, bar>{}); } This one makes only [gcc] unhappy. Error message: prog.cc: In function

clang 4 build error on <functional> with c++1z

喜你入骨 提交于 2019-11-30 03:24:12
问题 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

Is it undefined behavior to `reinterpret_cast` a `T*` to `T(*)[N]`?

早过忘川 提交于 2019-11-30 03:01:02
Consider the following scenario: std::array<int, 8> a; auto p = reinterpret_cast<int(*)[8]>(a.data()); (*p)[0] = 42; Is this undefined behavior ? I think it is. a.data() returns a int* , which is not the same as int(*)[8] The type aliasing rules on cppreference seem to suggest that the reinterpret_cast is not valid As a programmer, I know that the memory location pointed by a.data() is an array of 8 int objects Is there any rule I am missing that makes this reinterpret_cast valid? An array object and its first element are not pointer-interconvertible * , so the result of the reinterpret_cast

why doesn't std::any_cast support implicit conversion?

非 Y 不嫁゛ 提交于 2019-11-30 02:46:19
Why does std::any_cast throw a std::bad_any_cast exception when an implicit conversion from the actual stored type to the requested type would be possible? For example: std::any a = 10; // holds an int now auto b = std::any_cast<long>(a); // throws bad_any_cast exception Why is this not allowed and is there a workaround to allow an implicit conversion (in case the exact type that std::any holds is unknown)? std::any_cast is specified in terms of typeid . To quote cppreference on this: Throws std::bad_any_cast if the typeid of the requested ValueType does not match that of the contents of