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...

New paper: N3535, C++ Stream Mutexes -- 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: N3535

Date: 2013-03-06

C++ Stream Mutexes

by Lawrence Crowl

Excerpt:

At present, stream output operations guarantee that they will not produce race conditions, but do not guarantee that the effect will be sensible. Some form of external synchronization is required. Unfortunately, without a standard mechanism for synchronizing, independently developed software will be unable to synchronize.

 

This paper proposes a standard mechanism for locking streams...

New paper: N3531, User-defined Literals for Standard Library Types -- Peter Sommerlad

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: N3531

Date: 2013-03-08

User-defined Literals for Standard Library Types (version 3)

by Peter Sommerlad

Excerpt:

The standard library is lacking pre-de fined user-defi ned literals, even though the standard reserves names not starting with an underscore for it. Even the sequence of papers that introduced UDL to the standard contained useful examples of suffixes for creating values of standard types such as s for std::string, h for std::chrono::hours and i for imaginary parts of complex numbers.

Discussion on the reflector in May 2012 and in Portland Oct 2012 showed demand for some or even many pre-de fined UDL operators in the standard library...

New page: Papers and Mailings

There's a new page under Standardization -> Meetings and Participation that answers common questions about "what are papers and mailings all about?"

Papers and Mailings

This is timely information, because the pre-meeting mailing deadline is just a week away -- next Friday, March 15.

We'll continue to expand this and other standardization information to answer frequently asked questions and keep it current.

 

New paper: N3536, C++ Sized Deallocation -- Lawrence Crowl

A new WG21 paper is available:

Document number: N3536

Date: 2013-03-05

C++ Sized Deallocation

by Lawrence Crowl

 

Excerpt:

Problem

With C++11, programmers may define a static member function operator delete that takes a size parameter indicating the size of the object to be deleted. The equivalent global operator delete is not available. This omission has unfortunate performance consequences.

Modern memory allocators often allocate in size categories, and, for space efficiency reasons, do not store the size of the object near the object. Deallocation then requires searching for the size category store that contains the object. This search can be expensive, particularly as the search data structures are often not in memory caches.

Solution

Permit implementations and programmers to define sized versions of the global operator delete. The compiler shall call the sized version in preference to the unsized version when the sized version is available.
...