I get a linker error with the following code:
#include <regex>
int main()
{
std::regex rgx("ello");
return 0;
}
test.o: In function `basic_regex':
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/tr1_impl/regex:769: undefined reference to `std::basic_regex<char, std::regex_traits<char> >::_M_compile()'
collec...
Ideally I would like a following examples to work, but I guess some of it is not implementable in C++.
{
typedef StrongEnum<Red=0, Green=1, Blue=2> Color; // not a C++ syntax
Color c = Color::Red; // static const
Color d; //error: default constructor is private
Color d = c;
Color e = Color::OfInt(5); // ifdef DEBUG - Runti...
Could you give an example where static_assert(...) 'C++0x' would solve the problem in hand elegantly?
I am familiar with run-time assert(...). When should I prefer static_assert(...) over regular assert(...)?
Also, in boost there is something called BOOST_STATIC_ASSERT, is it the same as static_assert(...)?
...
Hi,
in C++ Template Metaprogramming : Concepts, Tools, and Techniques from Boost and Beyond
... One drawback of expression templates is that they tend to encourage writing large, complicated expressions, because evaluation is only delayed until the assignment operator is invoked. If a programmer wants to reuse some intermediate res...
Is there any official, or inofficial, #defines for when a compiler is Cpp0x compliant?
Even better, for specific Cpp0x functionality (~#cpp0xlambda, #cpp0xrvalue etc)?
(Haven't found anything about this on the net)
...
I was reading 'Want Speed? Pass by Value' on the C++ Next blog and created the following program to get a feel for copy elision and move semantics in C++0x: http://pastebin.com/f39c826c6
However I am perplexed by one thing.
Here is the output I get when compiled in release mode on Visual C++ 10.0 (Beta 2):
Move assign from RVO:
...
Hello,
after some years in Java and C# now I'm back to C++. Of course my programming style is influenced by those languages and I tend to feel the need of a special component that I used massively: the HASH MAP. In STL there is the hash_map, that GCC says it's deprecated and I should use unordered_map. So I turned to it. I confess I'm n...
I've recently encountered what I think is a false-sharing problem in my application, and I've looked up Sutter's article on how to align my data to cache lines. He suggests the following C++ code:
// C++ (using C++0x alignment syntax)
template<typename T>
struct cache_line_storage {
[[ align(CACHE_LINE_SIZE) ]] T data;
char pad[ C...
This is a question in two parts, the first is the most important and concerns now:
Are you following the design and evolution of C++0x? What blogs, newsgroups, committee papers, and other resources do you follow?
Even where you're not using any new features, how have they affected your current choices?
What new features are you using ...
Hello,
Googling nor binging "VC++ What's new C++0x" gives me nothing that tells me what is new.Is there an official page at msdn or something similiar that contains the information for VC++ 10? I've seen such for C#,there must be one for what I'd enjoy to read.
If not, please list the new features available in Visual Studio 2010 for VC...
I'm a little curious about some of the new features of C++0x. In particular range-based for loops and initializer lists. Both features require a user-defined class in order to function correctly.
I came accross this post, and while the top-answer was helpful. I don't know if it's entirely correct (I'm probably just completely misunderst...
Hi,
Is there a rule of thumb to decide when to use the old syntax () instead of the new syntax {}?
To initialize a struct:
struct myclass
{
myclass(int px, int py) : x(px), y(py) {}
private:
int x, y;
};
...
myclass object{0, 0};
Now in the case of a vector for example, it has many constructors. Whenever I do the following:
...
What is a good place to learn about the new C++ 0x features? I understand that they may not have been fully finalized yet but it would be nice to get a head start. Also, what compilers currently support them?
...
Hi,
I have a question about which style is preferred: std::bind Vs lambda in C++0x. I know that they serve -somehow- different purposes but lets take an example of intersecting functionality.
Using lambda:
uniform_int<> distribution(1, 6);
mt19937 engine;
// lambda style
auto dice = [&]() { return distribution(engine); };
Using bind...
Hi All,
C++ Standards committe is to publish the new standards for the language we all love so much in 2010 and the biggest support that is being provided, is for multi-threaded applications.... this sounds exciting .... any more inputs on this???? ...
Thanks in advance....
...
Hello,
I'm trying to work with lambda's in C++ after having used them a great deal in C#. I currently have a boost tuple (this is the really simplified version).
typedef shared_ptr<Foo> (*StringFooCreator)(std::string, int, bool)
typedef tuple<StringFooCreator> FooTuple
I then load a function in the global namespace into my FooTuple...
I'm trying to determine if C++0x features are available when compiling. Is there a common preprocessor macro? I'm using Visual Studio 2010's compiler and Intel's compiler.
...
I know that as of the C++03 standard, function-scope static initializations are not guaranteed to be thread safe:
void moo()
{
static std::string cat("argent"); // not thread safe
...
}
With the C++0x standard finally providing standard thread support, are function-scope static initializations required to be thread safe?
...
While doing variadic template programming in C++0x on GCC, once in a while I get an error that says "Sorry, unimplemented: cannot expand 'Identifier...' into a fixed-length arugment list." If I remove the "..." in the code then I get a different error: "error: parameter packs not expanded with '...'".
So if I have the "..." in, GCC c...
So I was reading about the memory model that is part of the upcoming C++0x standard. However, I'm a bit confused about some of the restrictions for what the compiler is allowed to do, specifically about speculative loads and stores.
To start with, some of the relevant stuff:
Hans Boehm's pages about threads and the memory model in C++0...