Why is noexcept checked dynamically? -- StackOverflow

Quick A: Because exceptions occur (or not) dynamically.

Why is C++0x's noexcept checked dynamically?

I am curious about the rationale behind noexcept in the C++0x FCD. throw(X) was [deprecated], but noexcept seems to do the same thing. Is there a reason that noexcept isn't checked at compile time? It seems that it would be better if these functions were checked statically that they only dcalled throwing functions within a try block.

What's the difference between push_back vs emplace_back? -- StackOverflow

Quick A: When correctly implemented per the standard, you get in-place construction with perfect forwarding.

Longer question:

push_back vs emplace_back

I'm a bit confused regarding the difference between push_back and emplace_back.

 

void emplace_back(Type&& _Val);
void push_back(const Type& _Val);
void push_back(Type&& _Val);

As there is a push_back overload taking a rvalue reference I don't quite see what the purpose of emplace_back becomes?

AESOP: Auto-parallelizing LLVM

An interesting development. Note that this is a research project, not a commercial product.

AESOP

The autoparallelizing compiler for shared-memory computers

AESOP is a high-performance, open-source compiler developed as LLVM plugins at the University of Maryland. Unlike many research compilers, AESOP is designed to handle real-world code rather than small, simple kernels. For example, AESOP can compile SPEC2006 and OMP2001 benchmarks, and our automated test suite consists of over 2 million lines of code. Still, we warn that AESOP is still just a 2-person research project, and we do not claim it to be production-ready.

 

By leveraging existing LLVM frontends and performing its analysis and transformations at the bytecode level, AESOP can serve as a drop-in replacement for clang, gcc, g++ and gfortran.

AESOP is free software, primarily tested targeting 32-bit x86 Linux. However, parts of it are likely to work wherever LLVM works.

 

Note: We're currently working on a whitepaper-style technical report on AESOP, which we plan to make available in April 2013.

Runtime-Compiled C++ -- "Edit and Continue"++ for MS VC++, gcc, Clang/LLVM

Very cool work:

Runtime-Complied C++ blog

This technique allows you to change your C++ code while it's running.

It uses no scripting, no VM, no external tools -- you can apply it to your own code and you can continue to use your favourite IDE. We think the quit-recompile-restart-reload cycle we're all used to could soon be a thing of the past.

If this is your first visit, watch the teaser video on the left.

If you want to know more, start here

dougbinks writes on the Reddit comment thread:

Compiling and loading code at runtime certainly isn't new, but what we're trying to do is develop a permissive open source portable and standard C++ solution which makes it easy to use. Cling is another similar project, but it uses compiler changes to LLVM so you need to use that compiler, whereas our solution requires only small changes to get it working with any compiler (currently supporting Visual Studio, gcc, clang/llvm).

What does std::function do that function pointers don't? -- StackOverflow

Quick A: A lot. They can bind to anything callable, not just functions. And they can perform conversions on parameter and return types.

Is there a use case for std::function that is not covered by function pointers, or is it just syntactic sugar?

The notation for std::function is quite nice when compared to function pointers. However, other than that, I can't find a use case where it couldn't be replaced by pointers. So is it just syntactic sugar for function pointers?

DDS Programming Using Modern C++ -- Sumant Tambe

For those in the Bay area this week, the ACCU USA Chapter is presenting the following talk:

DDS Programming using Modern C++

Speaker: Sumant Tambe

Date: March 13, 2013

Location: Symantec, VCAFE building, 350 Ellis Street (near E. Middlefield Road), Mountain View, CA USA 94043

Sumant writes:

Resurgence of C++ is spreading in many industries. International computer system standards that target C++ for application portability, are quickly adopting modern C++. At the Object Management Group (OMG) -- an international standards consortium -- the DDS-PSM-Cxx and the IDL2C++11 standards have been ahead of the curve. The DDS-PSM-Cxx is among the family of standards around the core Data Distribution Service (DDS) standard for developing high-performance distributed real-time systems. ...

I’m privileged to talk about the DDS-PSM-Cxx standard in a local event organized by the San Francisco Bay Area Association of C/C++ Users (ACCU). This is a great after-hours free-of-cost get-together for anyone who wants to know more about C++. The event will take place on March 13th in Mountain View not far from the RTI HQ.

C++ to JavaScript with Emscripten

Want to run your C++ code in a browser? Check out this project that converts LLVM bitcode to JavaScript™. From the project homepage:

Emscripten is an LLVM to JavaScript™ compiler. It takes LLVM bitcode (which can be generated from C/C++ using Clang, or any other language that can be converted into LLVM bitcode) and compiles that into JavaScript™, which can be run on the web (or anywhere else JavaScript™ can run).

Using Emscripten, you can

  • Compile C and C++ code into JavaScript™ and run that on the web
  • Run code in languages like Python as well, by compiling CPython from C to JavaScript™ and interpreting code in that on the web

They even have Qt demos running!

Continue reading...

What new capabilities do user-defined literals add to C++? -- StackOverflow

Over the past year, UDLs have started to become available in some popular C++ compilers, including gcc 4.7 and Clang 3.1. As people are adopting those compilers in real code and starting to be ablel to use this feature, a natural question is how useful they are and how to use them:

What new capabilities do user-defined literals add to C++?

C++11 introduces user-defined literals which will allow the introduction of new literal syntax based on existing literals (int, hex, string, float) so that any type will be able to have a literal presentation.

Examples:

// imaginary numbers
std::complex<long double> operator "" _i(long double d) // cooked form
{
    return std::complex<long double>(0, d);
}
auto val = 3.14_i; // val = complex<long double>(0, 3.14)

// binary values
int operator "" _B(const char*); // raw form
int answer = 101010_B; // answer = 42

// std::string
std::string operator "" _s(const char* str, size_t /*length*/)
{
    return std::string(str);
}
auto hi = "hello"_s + " world"; // + works, "hello"_s is a string not a pointer

// units
assert(1_kg == 2.2_lb); // give or take 0.00462262 pounds

At first glance this looks very cool but I'm wondering how applicable it really is, [...] do you feel this feature will justify itself? What other literals would you like to define that will make your C++ code more readable?

New paper: N3538, Pass by Const Reference or Value -- Lawrence Crowl

A new WG21 paper is available. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N3538

Date: 2013-03-06

Pass by Const Reference or Value

by Lawrence Crowl

Excerpt:

Efficiency and expressiveness are hallmarks of C++, but sometimes those hallmarks conflict in ways that force programmers to compromise on one or the other. The progammer's choice of passing a given argument by const reference or by value is one of those compromises. That compromise has become more of a problem with modern calling conventions.

In this paper, we describe the problem, discuss possible approaches to reduce the problem, and explore a solution that introduces a new language feature...