Copy of libcxx templates in my own namespace

I am thinking about making a copy of some of the libcxx STL templates such as basic_string and vector and moving them into my own namespace. What do you think of this idea, and is anyone else doing this?


My goal is to rename and use these templates in the published API of my libraries. As recommended by C++ Coding Standards #63, I cannot use the std templates provided by the compiler vendor(s), as that would force the users of my library to use the same compilers and options that I use. Instead, I must provide and control the format of all of the types that appear in my API. Rather than writing my own version of string, vector, etc., I thought it would make sense to repackage the libcxx implementations. Does that make sense to you?

My Approach.

My approach has been to make a copy of a subset of the libcxx include files and change them so as to put all of the templates into my own namespace (rather than std) and to apply a prefix to the names of the templates and functions. This has worked out pretty well, as I can compile and run my code using my renamed copy of the libcxx templates alongside the real libcxx templates without any apparent confusion. Do you agree that this approach is feasible, or is there a better way?

Porting to MSC.

I must build the code on multiple platforms using several compilers, including clang, GCC, and the Microsoft Visual Studio 11.0 cl compiler. I have not much trouble with clang or GCC. I have hit a few problems trying to use the MSC compiler, however.

I have read that a port of libcxx to MSC is in progress, and I see the ifdefs in __config for _MSC_VER. I wonder what the goal for that port is?

I would like to share my experience with trying to get MSC to compile the libcxx templates. Is this the right mailing list for doing that?

Thanks in advance for your advice and comments.

Sam Wilson

Bentley Systems, Inc.

Please be sure to abide by the terms of use by retaining the copyright header at the top of each file you copy from, LICENSE.TXT, and CREDITS.TXT.