[vtk-developers] Use of std:: in vtk

Bill Lorensen bill.lorensen at gmail.com
Mon Dec 14 17:14:45 EST 2009

Perhaps we could remove the commit check for std::string,etc. and
std::cout for the Examples directory. I hate to encourage new users to
use vtkstd::.

On Mon, Dec 14, 2009 at 5:10 PM, Brad King <brad.king at kitware.com> wrote:
> Bill Lorensen wrote:
>> Folks,
>> Coming from the itk world, we always use std::cout and std:: for
>> string, vector, map, etc. In trying to check in some new examples, my
>> pre-commit failed with the message:
>> GenerateCubesFromLabels.cxx has used the std:: or vtkstd:: to access streams.
>> For example, std::cout or vtkstd::endl.
>> For VTK, you must not use a namespace for streams.
>> Common/vtkIOStream.h for list of using directives in VTK.
> The vtkstd namespace is used for STL, while the global namespace is
> used for streams.
>> I'm sure there used to be a good reason for this in the old days, but
>> is this restriction still necessary?
> I don't know if we still support platforms that don't have std:: for
> everything.  Someone would have to check this.  It should be verified
> both that streams are in std and that STL is in std.  I know we used
> to have
>  VS6 - Supports both old and ansi streams, old streams have no std
>  HP  - At least one old HP compiler had no std for STL
>  Others???
> If it were deemed safe I would certainly be interested in seeing use
> of std:: in VTK.
>> Also, to use std::string I needed
>> to change it to vtkstd::string. It makes one wonder how std::string
>> differs from vtkstd::string.
> It's just a typedef (or perhaps using declaration) to either ::string
> or std::string depending on what the compiler provides.
>> I did change std::cout to cout, but this is in conflict with itk and
>> probably other styles.For instance, I noticed that CMake source code
>> uses std::string, vector, map etc.
> CMake is an application that does not provide public header files.
> It can get away with moving things into the std namespace outright,
> and does so to get std:: to work everywhere.
> -Brad

More information about the vtk-developers mailing list