c++17

Will I be able to declare a constexpr lambda inside a template parameter?

萝らか妹 提交于 2019-12-24 09:29:36
问题 I know it's like opening the Pandora box but it doesn't stop bothering me. Consider a simple example: #include <type_traits> template <auto> struct Foo: std::false_type { }; template <> struct Foo<[](){return 1;}()>:std::true_type { }; int main() { static_assert(Foo<1>::value); } I know lambdas cannot be declared inside unevaluated context, but obviously this is not the case here. What is even more weird clang 5.0.0 (which, I guess, first partially supports constexpr lambda) does compile it.

How to run a process and get its output using c++ libboost?

送分小仙女□ 提交于 2019-12-24 08:46:49
问题 I'm trying to run an external shell command and read its output using the Boost libraries for C++ but it seems that either the command is not running or I just can't access the output. I'm using their documentation as example and wrote this: #include <boost/process.hpp> namespace bp = boost::process; bool is_process_running(std::string p_name){ string cmd = "ps aux 2>&1"; bp::ipstream out; std::string line; bp::child c(cmd, bp::std_out > out); // the while is supposed to read each line of the

Why am I getting this Android Studio error: “recompile with -fPIC”?

元气小坏坏 提交于 2019-12-24 08:23:09
问题 I am using NDK 18 and compiling a static library separately using the x86_64 NDK standalone toolchain. I can link it successfully but when I try to access the library in a non-trivial way I am getting dozens of errors when building saying things like: ... requires dynamic R_X86_64_PC32 reloc against '_ZZN4seal4util21get_msb_index_genericEPmmE15deBruijnTable64' which may overflow at runtime; recompile with -fPIC See my previous question for details on my build files: Why am I still getting

[LLVM-9 clang-9 OSX]: std::filesystem::path unrecognized

99封情书 提交于 2019-12-24 07:53:12
问题 Hello after upgrading on OSX Mojave to the version LLVM-9 using brew upgrade llvm I got the following error: In file included from /Users/roman/CLionProjects/Milerius/antara-gaming-sfml-template/cmake-build-debug/_deps/antara-gaming-sdk-src/modules/core/antara/gaming/core/real.path.cpp:17: /Users/roman/CLionProjects/Milerius/antara-gaming-sfml-template/cmake-build-debug/_deps/antara-gaming-sdk-src/modules/core/antara/gaming/core/real.path.hpp:23:22: fatal error: 'path' is unavailable:

g++ with std::exclusive_scan (c++17)

╄→гoц情女王★ 提交于 2019-12-24 07:18:46
问题 Is std::exclusive_scan implemented with libstdc++ ? I'm trying to use the function but I'm getting compilation error saying std::exclusive_scan is not found. Here is the sample code. With clang compiler I'm able to run the code without stdlib=libc++ option. I've included the correct header file ( <numeric> ) and compiling using std=c++17 flag. 来源: https://stackoverflow.com/questions/55771604/g-with-stdexclusive-scan-c17

g++ with std::exclusive_scan (c++17)

依然范特西╮ 提交于 2019-12-24 07:18:08
问题 Is std::exclusive_scan implemented with libstdc++ ? I'm trying to use the function but I'm getting compilation error saying std::exclusive_scan is not found. Here is the sample code. With clang compiler I'm able to run the code without stdlib=libc++ option. I've included the correct header file ( <numeric> ) and compiling using std=c++17 flag. 来源: https://stackoverflow.com/questions/55771604/g-with-stdexclusive-scan-c17

Why can't a static constexpr member variable be passed to a function?

南笙酒味 提交于 2019-12-24 05:58:30
问题 The following code produces an undefined reference to 'Test::color' . #include <iostream> struct Color{ int r,g,b; }; void printColor(Color color) { //printing color } class Test { static constexpr Color color = {242,34,4}; public: void print(){ printColor(color); } }; int main() { Test test; test.print(); return 0; } Why does this code produce the above error and what is the best way to avoid it, considering I want to use the latest version of the standard, C++17? Should I define the static

Why does std::filesystem::path::append replace the current path if p starts with root path

守給你的承諾、 提交于 2019-12-24 05:04:22
问题 Given below code: #include <iostream> #include <filesystem> namespace fs = std::filesystem; int main() { fs::path fsBase = "/base"; fs::path fsAppend = "/append"; auto fsResult = fsBase / fsAppend; std::cout << "fsResult: " << fsResult << std::endl; return 0; } Usually, the expected result is /base/append , but it actually gives /append . The description of fs::path::append does indicate this behavior: If p.is_absolute() || (p.has_root_name() && p.root_name() != root_name()), then replaces

Create a directory for every element of a path if it does not exist

时光总嘲笑我的痴心妄想 提交于 2019-12-24 04:01:50
问题 In C++, I want to create a directory from a path "path/that/consists/of/several/elements" . Also I want to create all parent directories of that directory in case they are not existing. How to do that with std C++? 回答1: std::experimental::filesystem/std::filesystem (C++14/C++17) provides create_directories(). It creates a directory for every path element if it does not already exist. For that it executes create_directory() for every such element. #include <experimental/filesystem> #include

Deduction guides and variadic class templates with variadic template constructors - mismatched argument pack lengths

倖福魔咒の 提交于 2019-12-24 03:49:08
问题 Consider the following class definition and deduction guide: template <typename... Ts> struct foo : Ts... { template <typename... Us> foo(Us&&... us) : Ts{us}... { } }; template <typename... Us> foo(Us&&... us) -> foo<Us...>; If I try to instantiate foo with explicit template arguments , the code compiles correctly: foo<bar> a{bar{}}; // ok If I try to instantiate foo through the deduction guide ... foo b{bar{}}; g++7 produces a compiler error: prog.cc: In instantiation of 'foo<Ts>::foo(Us ..