c++14

wxWidgets runtime error (Mismatch version)

不打扰是莪最后的温柔 提交于 2020-01-14 10:22:49
问题 I have a problem at start the program: Fatal Error: Mismatch between the program and library build versions detected. The library used 3.0 (wchar_t,compiler with C++ ABI 1010,wx containers,compatible with 2.8), and your program used 3.0 (wchar_t,compiler with C++ ABI 1009,wx containers,compatible with 2.8). My cmake settings: cmake_minimum_required(VERSION 3.0) project(simple) set(CMAKE_BUILD_TYPE Release) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS} -Wall -std=c++14") find

assigning Rvalue reference to Lvalue reference

ぐ巨炮叔叔 提交于 2020-01-14 09:47:28
问题 int&& rv = 10; int& lv = rv; //no error How is this possible? Is this related to "reference collapsing rule"? 回答1: int&& rv = 10; int& lv = rv; //no error First of all, a named object is never an rvalue. Second, since rv is named object, it is not a rvalue, even though it binds to rvalue. Since rv is lvalue, it can bind to lvalue without any problem. Note that rvalue-ness is a property of an expression , not a variable . In the above example, an rvalue is created out of 10 and binds to rv ,

Does a placeholder in a trailing-return-type override an initial placeholder?

∥☆過路亽.° 提交于 2020-01-14 08:27:09
问题 g++ appears to accept any combination of auto and decltype(auto) as initial and trailing return types: int a; auto f() { return (a); } // int auto g() -> auto { return (a); } // int auto h() -> decltype(auto) { return (a); } // int& decltype(auto) i() { return (a); } // int& decltype(auto) j() -> auto { return (a); } // int decltype(auto) k() -> decltype(auto) { return (a); } // int& However, clang rejects j and k , saying: error: function with trailing return type must specify return type

std::less<void> and pointer types

元气小坏坏 提交于 2020-01-14 07:17:35
问题 std::less<T *> is guaranteed to provide total order, regardless of whether both pointers point into the same array. In the latest draft of the standard, is the same true for the transparent function object std::less<void> ( std::less<> ) when you call its operator() ? Obviously, the same question applies to std::greater , but I assume they are specified the same. 回答1: The current draft from github does not contain any language to that effect; in fact, its definition of less<> says explicitly

How to check if class has pointers in C++14

孤人 提交于 2020-01-14 02:00:02
问题 I've got the classes: struct A { // has no pointer members, POD - it's fine int a, b; char c; }; struct B { // has no pointer members, but not POD - it's still fine int a, b; std::string s; }; struct C { // has pointer members, it's not fine int a,b; char* cs; }; I need to detect in compile time if any class has the properties of struct C , i.e. has pointers as members. Short reasoning: I need to assure a user-defined type can be safely serialized and deserialized to some buffer by copying or

Switch in constexpr function

血红的双手。 提交于 2020-01-13 12:16:12
问题 Found the following statement in Wiki: C++11 introduced the concept of a constexpr-declared function; a function which could be executed at compile time. Their return values could be consumed by operations that require constant expressions, such as an integer template argument. However, C++11 constexpr functions could only contain a single expression that is returned (as well as static_asserts and a small number of other declarations). C++14 relaxes these restrictions. Constexpr-declared

No matching function std::forward with lambdas

拟墨画扇 提交于 2020-01-13 10:29:33
问题 Consider the following code, inspired from Barry's answer to this question: // Include #include <tuple> #include <utility> #include <iostream> #include <type_traits> // Generic overload rank template <std::size_t N> struct overload_rank : overload_rank<N - 1> { }; // Default overload rank template <> struct overload_rank<0> { }; // Prepend argument to function template <std::size_t N, class F> auto prepend_overload_rank(F&& f) { using rank = overload_rank<N>; return [f = std::forward<F>(f)]

No matching function std::forward with lambdas

烈酒焚心 提交于 2020-01-13 10:28:11
问题 Consider the following code, inspired from Barry's answer to this question: // Include #include <tuple> #include <utility> #include <iostream> #include <type_traits> // Generic overload rank template <std::size_t N> struct overload_rank : overload_rank<N - 1> { }; // Default overload rank template <> struct overload_rank<0> { }; // Prepend argument to function template <std::size_t N, class F> auto prepend_overload_rank(F&& f) { using rank = overload_rank<N>; return [f = std::forward<F>(f)]

What is C++ Technical Specification?

无人久伴 提交于 2020-01-13 08:03:12
问题 Concepts-lite C++ (proposal N3701) feature is not included in C++1y standard, but it is said it will be published as Technical Specification. What does it exactly mean? Will it automatically become a standard feature in next C++ releases? 回答1: I usually don't like copy-paste answer's, but I think it is pretty well explained here: Starting in 2012, the committee has transitioned to a “decoupled” model where major pieces of work progress independently from the Standard itself and can be

How to Compile C++14 code for Android?

时光毁灭记忆、已成空白 提交于 2020-01-12 14:30:50
问题 Is it possible to compile C++14 source code for Android with ndk10d? I've tried both g++ and clang compilers but it seems that -std=c++14 -std=c++1y flags do not work. If I use c++_static as my APP_STL, i get the following error: User/someone/Software/Android/android-ndk-r10d/platforms/android-17/arch-arm/usr/include/locale.h:55:1: error: empty struct has size 0 in C, size 1 in C++ Edit: I am using Mac OSX 10.10.4 with Xcode 6.3.2 (able to compile C++14 for iOS). 回答1: I use android-ndk-r12b