standards

To use or not to use C++0x features [duplicate]

跟風遠走 提交于 2020-01-03 07:17:36
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: How are you using C++0x today? I'm working with a team on a fairly new system. We're talking about migrating to MSVC 2010 and we've already migrated to GCC 4.5. These are the only compilers we're using and we have no plans to port our code to different compilers any time soon. I suggested that after we do it, we start taking advantage of some of the C++0x features already provided like auto. My co-worker

How do I share a page or link using the latest Facebook SDK for Android

允我心安 提交于 2020-01-03 05:19:06
问题 I am trying to make an application which integrates facebook and twitter. I have started to implement Facebook for my application. And I have managed to do that using recently released Facebook SDK for android example but now I am looking to share a page or a link to facebook using the same SDK but have no clue how to do it. Can anyone please let me know how to do it. I am really stuck on this from long time. 回答1: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

What is the official standard for pthreads?

穿精又带淫゛_ 提交于 2020-01-02 20:22:19
问题 I am trying to find the document that specifies the standard for pthreads. I've seen various links which point to IEEE 1003.1c-1995 (i.e. Wikipedia or OpenGroup). However when I searched for this document on the IEEE standards site I eventually found this page which said "Superseded Standard." The IEEE page for 1003.1c-1995 did have a note that said: "Abstract not available. See ISO/IEC 9945-1." Searching for that on Google led me to a page for ISO/IEC 9945-1:1996 but the status said

How to implement std::when_any without polling?

元气小坏坏 提交于 2020-01-02 19:30:14
问题 Consider http://en.cppreference.com/w/cpp/experimental/when_any. The following is just a naive and simplified implementation: #include <future> template<typename Iterator> auto when_any(Iterator first, Iterator last) { while (true) { for (auto pos = first; pos != last; ++pos) { if (pos->is_ready()) { return std::move(*pos); } } } } I am not satisfied because it is a busy polling in an infinite loop. Is there a way to avoid busy polling? 回答1: A polling free version would launch 1 thread per

Chaining operation and order of evaluation on the same object

橙三吉。 提交于 2020-01-02 13:58:24
问题 Consider a class MyClass with: a member function myClass& myFunction1(int) that modifies the object and returns *this a member function int myFunction2() const that does not modify the object Does the C++11/14 standard guarantee that: myclass.myFunction1(myclass.myFunction2()).myFunction1(myclass.myFunction2()); is equivalent to: myclass.myFunction1(myclass.myFunction2()); myclass.myFunction1(myclass.myFunction2()); 回答1: No. The compiler can first call myclass.myFunction2() twice and then do

What's the life-time of a function parameter (citation needed)? [closed]

拜拜、爱过 提交于 2020-01-02 07:18:32
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . Is the life-time of a function parameter equal of an unnamed temporary passed as an 'rvalue' reference (which is equal of the expression called the function)? My 'gcc' compiler shows that it is. But I want to see an actual standard document that states it too (possible the newest 'C++11' or 'C++14'

What's the life-time of a function parameter (citation needed)? [closed]

南笙酒味 提交于 2020-01-02 07:18:05
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . Is the life-time of a function parameter equal of an unnamed temporary passed as an 'rvalue' reference (which is equal of the expression called the function)? My 'gcc' compiler shows that it is. But I want to see an actual standard document that states it too (possible the newest 'C++11' or 'C++14'

Strict-aliasing and pointer to union fields

为君一笑 提交于 2020-01-02 06:21:08
问题 I've got a question about strict-aliasing rules, unions and standard. Assume we have the following code: #include <stdio.h> union { int f1; short f2; } u = {0x1}; int * a = &u.f1; short * b = &u.f2; int main() { u.f1 = 1; *a += 1; u.f2 = 2; *b *= 2; printf( "%d %hd\n", *a, *b); return 0; } Now let's look how it works: $ gcc-5.1.0-x86_64 t.c -O3 -Wall && ./a.out 2 4 $ gcc-5.1.0-x86_64 t.c -O3 -Wall -fno-strict-aliasing && ./a.out 4 4 We can see that strict-aliasing breaks dependencies.

Does standard C++11 guarantee that temporary object passed to a function will have been created before function call?

馋奶兔 提交于 2020-01-01 15:56:22
问题 Does standard C++11 guarantee that all 3 temporary objects have been created before the beginning performe the function? Even if temporary object passed as: object rvalue-reference passed only member of temporary object http://ideone.com/EV0hSP #include <iostream> using namespace std; struct T { T() { std::cout << "T created \n"; } int val = 0; ~T() { std::cout << "T destroyed \n"; } }; void function(T t_obj, T &&t, int &&val) { std::cout << "func-start \n"; std::cout << t_obj.val << ", " <<

C++: Calculate number of possible floating-point values within given range

大城市里の小女人 提交于 2020-01-01 13:57:04
问题 I'm working on a cryptography application ,using Crypto++ As an obscure part of this application, I need to determine the maximum number of unique float values that can exist within a certain numeric range. Obviously there are infinite numbers between 0 and 1 in reality - but not all of them can be represented by a unique float value. I have a minimum float value, and a maximum float value. I need to determine the number of possible float values inside this range. This is tricky, because