c++14

Ambiguity error in C++17 (template template parameters and default arguments issue)

老子叫甜甜 提交于 2019-12-09 07:39:38
问题 I have code which is differently interpreted by g++ with the c++14 and c++17 standard flags: #include <iostream> #include <vector> template<class T, class A> void func(const std::vector<T, A>&v) { std::cout << 1 << std::endl; } template<typename T, template <typename>class Vector> void func(const Vector<T>&v) { std::cout << 2 << std::endl; } void f() { std::vector<int> v; func(v); } int main() { f(); return 0; } When I'm trying compile this code with command g++ -std=c++14 -Wall -pedantic

Are C++14 digit separators allowed in user defined literals?

梦想的初衷 提交于 2019-12-09 07:23:28
问题 While clang compiles the following line, g++ 6.1 complains about the digit separator (see live example on Coliru): auto time = 01'23s; Which compiler, if any, is correct according to the C++14 standard (N3796)? Otherwise, is allowing digit separators (§2.14.2) just an implementation detail in the user-defined literals (§2.14.8) of the <chrono> library (§20.12.5.8)? IMHO it should be not, since these literals are defined on unsigned long long parameters. I remember Howard Hinnant using 10'000s

error: Microsoft Visual C++ 14.0 is required when installing python package

时光总嘲笑我的痴心妄想 提交于 2019-12-09 06:40:48
问题 I’m trying to download the package statsmodels by running in command prompt(admin) this command: pip3 install statsmodels and I get this error “error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools” Please note that I already installed Visual Studio 2015 and I also have Visual Studio 2013 installed on my machine. 回答1: Please download Visual C++ Build Tools 2015 Install the visualcppbuildtools

Multiple Variadic Parameter Pack for Template Class

蓝咒 提交于 2019-12-09 06:12:13
问题 I am using variadic parameter packs for policy based class design. template <APITypes APIType, class... Policies> class IShader : public Policies... { }; Policies are defined when called or with defaults if none are specified. The problem comes when I need to add another variadic parameter pack: template <AttributeType... Attributes, APITypes APIType, class... Policies> class IShader : public Policies... { }; This results in the error "Template parameter pack must be the last template

Generic lambda argument for std::pair

烂漫一生 提交于 2019-12-09 05:46:20
问题 I'm trying to see if this is possible in the C++14 generic lambda, but I cannot find a right way to express it (or perhaps it is not possible). The simplified example is: auto confirmOperation = [](auto pr){ assert(pr.second); }; The idea is that if you pass it an std::pair where the second is a bool (such as what is returned from emplace functions), it can look at this bool. If this was a template parameter instead, I could explicitly show the pair with the types of the pair as generic, but

Vector of typedefs

霸气de小男生 提交于 2019-12-09 03:41:25
问题 Is it possible in ANY way to have a vector of type(def)s in C++11/14 ? The first thing I tried was have a vector of a base class and somehow get the typedef from it's derived form but I can't get this to work whatever I try (not possible most likely). Pseudo-C++: class base { /* somehow access 'type' from derived */ } template <typename T> class derived : base { typedef T type; } vector<base*> vec; vec.push_back( new derived<int> ); vec.push_back( new derived<double> ); vec.push_back( new

Inject namespace experimental to std

拜拜、爱过 提交于 2019-12-09 02:53:14
问题 Is it bad or good parctice to inject namespace std::experimental into std like following? namespace std { namespace experimental { } using namespace experimental; } #include <experimental/optional> int main() { std::optional< int > o; return 0; } Or even in more modern form: #if __has_include(<optional>) # include <optional> #elif __has_include(<experimental/optional>) # include <experimental/optional> namespace std { using namespace experimental; } #else #error ! #endif int main() { std:

Build project with “experimental/filesystem” using cmake

淺唱寂寞╮ 提交于 2019-12-09 02:40:07
问题 I need to add a "experimental/filesystem" header to my project #include <experimental/filesystem> int main() { auto path = std::experimental::filesystem::current_path(); return 0; } So I used -lstdc++fs flag and linked with libstdc++fs.a cmake_minimum_required(VERSION 3.7) project(testcpp) set(CMAKE_CXX_FLAGS "-std=c++14 -lstdc++fs" ) set(SOURCE_FILES main.cpp) target_link_libraries(${PROJECT_NAME} /usr/lib/gcc/x86_64-linux-gnu/7/libstdc++fs.a) add_executable(testcpp ${SOURCE_FILES}) However,

C++14 value-initialization with deleted constructor

北城以北 提交于 2019-12-08 22:55:20
问题 I have some misunderstanding: Let's mark default constructor of struct A as deleted: struct A { A() = delete; }; The next instruction is well-formed and what's that effect?: A a{}; From cppreference value initilization: 1) If T is a class type with no default constructor or with a user-provided default constructor or with a deleted default constructor, the object is default-initialized. but then the effect of default initialization is: If T is a class type, the default constructor is called

Difference between GCC binary literals and C++14 ones?

前提是你 提交于 2019-12-08 22:23:58
问题 C++14 seems to be coming and compilers are already trying to implement the core features of this new revision. I was having a look at GCC support for these core features and noticed something about the binary literals part: GCC implements them but seems to make a difference between GNU binary literals and C++14 binary literals. Here are the respective references for both: GNU binary literals C++1y binary literals I tried to find some differences between the two of them since GCC seems to make