Toward Opaque Typedefs for C++1Y
Although this paper is self-contained, it logically follows our discussion, begun several years ago in N1706 and continued in N1891, of a feature oft-requested for C++: an opaque typedef , sometimes termed a strong typedef . The earlier of those works was presented to WG21 on 2004-10-20 during the Redmond meeting, and the later work was presented during the Berlin meeting on 2005-04-06. Both presentations resulted in very strong encouragement to continue development of such a language feature.1 Alas, the press of other obligations has until recently not permitted us to resume our explorations.
Flexible semi-automatic support for type migration of primitives for C/C++ programs
Type systems are crucial tools in the hands of developers to ensure an increased level of soundness to their programs, make them safer, and guard against bugs. However, in practice, the type system is not always used to its full capability, and trade-offs are made. The effects range from hindered code comprehension and wasted development effort to financial damages and even the risk of loss of life. Various widely used programming languages, such as C++, Java, Python, and Rust, are yet to implement constrained types as a language feature. While the usage of user-defined types is common in modern languages that support such elements, developers often resort to having their variables use the most common, fundamental, built-in or library types, such as int or string, and not encode invariants into the type system. In this paper, we describe a flexible, incremental, semi-automated type migration approach that allows transitioning from the use of fundamental coarse types to strong types. Previously, well-scaling type migration methods were restricted and required the existence of an already well-defined destination type. In our case, the new strong type to be created is not yet defined, but the required interface is discovered via static analysis. As refactoring tools would cease to function if the code is changed textually to a version that refers undefined symbols, a more granular approach was needed. In addition, our proposed method allows us to discover the mixing of conceptually distinct types during development while the original program continues to function.
Toward Opaque typedef s in C++0X
It is a common programming practice to use one data type directly as an implementation technique for another. This is facilitated by the C++ typedef facility, allowing the programmer to provide a synonym or alias (the name of the desired new type) for the existing type that is being used as the underlying implementation. In the standard library, for example, size_t is an alias for a native unsigned integral type; this provides a convenient and portable means for user programs to make use of an implementation-selected type that may vary across platforms.