Welcome to the code snippets page. This page, created on April 24, 2004, is meant to carry various code snippets that often accompany Andrei's articles. If you find bugs or have any comments about the code, feel free to email Andrei.
If you are looking for the source code of the Loki library, this isn't the place for it; you may want to take a look at the Modern C++ Design page, or head straight to Loki's page on Sourceforge.
For now, as promised, you can download YASLI's first artifact, yasli::vector. The legendary YASLI stands for "Yet Another Standard Library Implementation", and is meant to be an STL implementation that exploits type introspection and guarded platform assumptions at its best to yield lean and mean code. By definition, YASLI is the best implementation all around; however, it is also a non-existent one, because it was created in Yasland and we don't have full access to Yaslander technology yet. YASLI is often dreamed of by Andrei, but seldom worked on because Andrei's current main interest (and time sink) is his research.
| Component | Comments |
|---|---|
scpi: scp improved January 27, 2006 | scpi (scp improved) is intended to be a drop-in replacement for the scp utility that comes together with any Secure Shell (ssh) implementation. scpi implements the much-needed restartable downloads that scp famously doesn't support. |
SafeFormat July 7, 2005 | This code accompanies the article "Type-Safe Formatting" in C/C++ Users Journal, August 2005. It implements a simple printf emulation framework, which is typesafe at the cost of a slightly modified invocation syntax. Per popular demand, SafeFormat has been moved in the Loki project (where the link to the left will take you). |
flex_string January 10, 2004 | flex_string is a drop-in replacement for the standard string (std::basic_string, better known by its typedefed name, std::string. If you think that reimplementing a likely fine-tuned component of your standard library is not a very rewarding endeavor, think again. flex_string has a policy-based design allowing unparalleled control over its behavior and optimizations, and also allows you to define new implementations in only a few dozens of lines of code. If you're looking for controllable performance and predictible behavior with multiple threads, then flex_string might be of interest to you.
To find more about flex_string, you may want to read "A
Policy-Based The downloadable code consists of the flex_string header and a test suite that compares its behavior against std::string. Though no performance comparison suite is available at this time, Harmut Kaizer reported that simply dropping in flex_string in the Wave Boost Preprocessor improved its speed by 5-10%, depending on input. Justin Matthews contributed with flex_string_hash.h, an add-on for flex_string that allows using it with hash maps. Justin's code supports (and automatically recognizes) two implementations: STLPort and Microsoft Visual C++ 7.1. |
yasli::vector April 24, 2004 | This first component of the legendary YASLI is now available together with a simple test suite that compares yasli::vector's behavior against std::vector. (Many thanks to Casper Edward Aethelric Cody Clemence, who submitted a largely fixed version on January 13th, 2005.) As of now, the implementation illustrates the definition and use of a moving protocol, and has a number of known inefficiencies and a yet-unknown number of bugs. You are welcome to improve the former and report the latter.
Some bugs in MSVC 7.1 prevent the data moving protocol to function properly for certain data types, such as std::complex. That code has been commented out as of now. Unfortunately, the article that describes yasli::vector's design and implementation ("yasli::vector Is On The Move") is not available online; it is published in C/C++ Users Journal, June 2004. It will be available on this site 3 months after publication. |