Yesterday I was thinking about whether it would be possible to use the convenience of C++0x lambda functions to write callbacks for Windows API functions.
For example, what if I wanted to use a lambda as an EnumChildProc with EnumChildWindows? Something like:
EnumChildWindows(hTrayWnd, CALLBACK [](HWND hWnd, LPARAM lParam) {
//...
Does VC++ 2010 have support for C++0x's portable atomic type template?
...
There is a list for GCC; is there a similar list for Visual Studio 2010?
...
What are the best practices for using autoconf in conjunction
with shared_ptr and other TR1/BOOST C++0x templates so as to maximize
portability and maintainability?
With autoconf I can determine whether shared_ptr is
available as std::tr1::shared_ptr and/or boost::shared_ptr. Given
that the same feature has two different names, I have...
I read on the internet many tutorials that explained how to use lambdas with the standard library (such as std::find), and they all were very interesting, but I couldn't find any that explained how I can use a lambda for my own functions.
For example:
int main()
{
int test = 5;
LambdaTest([&](int a) { test += a; });
return...
C++0x N3092 states that monotonic_clock is optional:
20.10.5.2 Class monotonic_clock [time.clock.monotonic]
Objects of class monotonic_clock represent clocks for which values of time_point never decrease as physical time advances. monotonic_clock may be a synonym for system_clock if system_clock::is_monotonic is true.
The c...
Hi, I have written a small program , to understand how futures work in c++0x. while running the code I get an error like " error: 'printEn' was not declared in this scope". I am unable to understand what the problem is..Kindly point out what I am doing wrong here and if possible write the correct code for the same..
#include <future>
#i...
I would like to jump in learn C++0x, which has matured to a level I'm happy with.
Xcode on Snow Leopard 10.6 is currently at GCC 4.2.1, and the new features I'd like to try, like std::shared_ptr, lambdas, auto, null pointer constant, unicode string literals, and other bits and pieces, require at least 4.3 (I believe).
Ideally I'd use X...
Possible Duplicate:
forward/strong enum in VS2010
This question pointed to a wiki page for C++0x support which lists Strongly typed enums as Partially supported in VS10.
However the following is a compilation error:
enum class boolean { no, yes, maybe };
Any idea what constitutes partial support when the basic syntax is...
Important update: Apparently I drew the wrong conclusion when I asked this question. Thanks to the responses I found out the lambda function [=]() does work fine in a multithreaded scenario. My apologies for posing this confusing question. Please vote to close, as it was a non-issue.
In our company we've written a library function to ...
Is there a macro that tells me whether or not my compiler supports variadic templates?
#ifdef VARIADIC_TEMPLATES_AVAILABLE
template<typename... Args> void coolstuff(Args&&... args);
#else
???
#endif
If they are not supported, I guess I would simulate them with a bunch of overloads. Any better ideas? Maybe there are preprocessor li...
Hi All,
Below is a simple program in c++0x that makes use of packaged_task and futures. while compiling the program i get error : variable 'std::packaged_task pt1' has initializer but incomplete type
the program is below
#include <future>
#include <iostream>
using namespace std;
int printFn()
{
for(int i = 0; i < 100; i++)
...
Is there some equivalent class for C++1x's std::unique_ptr in the boost libraries? The behavior I'm looking for is being able to have an exception-safe factory function, like so...
std::unique_ptr<Base> create_base()
{
return std::unique_ptr<Base>(new Derived);
}
void some_other_function()
{
std::unique_ptr<Base> b = create_bas...
Are variadic constructors supposed to hide the implicitly generated ones, i.e. the default constructor and the copy constructor?
struct Foo
{
template<typename... Args> Foo(Args&&... x)
{
std::cout << "inside the variadic constructor\n";
}
};
int main()
{
Foo a;
Foo b(a);
}
Somehow I was expecting this to ...
My system compiler (gcc42) works fine with the TR1 features that I want, but trying to support newer compiler versions other than the systems, trying to accessing TR1 headers an #error demanding the -std=c++0x option because of how it interfaces with library or some hub bub like that.
/usr/local/lib/gcc45/include/c++/bits/c++0x_warning....
With the advent of threading facilities in the STL for the new C++ standard (C++0x), will it be better to change existing code that is using POSIX threading or even Windows threading to use STL threading?
...
In particular, the display of initialization lists is really bad:
vector<int> v({1,2,3});
will highlight the curly braces in red (denoting an error.)
...
This page says that GCC 4.5 has C++ raw string literals:
http://gcc.gnu.org/projects/cxx0x.html
But when I try to use the syntax from this page:
http://www2.research.att.com/~bs/C++0xFAQ.html#raw-strings
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s = R"[\w\\\w]";
}
I get this error:
/opt/...
What's the difference between async_read and async_receive?
...
I realize this is a ludicrous question for something that takes less than 2 seconds to implement. But I vaguely remember reading that one was introduced with the new standard.
I grep'ed VC10's headers and came up with nothing. Can you help? It's bugging me! :)
edit:
On second thought, the new functor I was remembering was probably the ...