Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-07-05 03:10:12


Edward Diener wrote:

>> I had in mind situation where there are two applications -- one which
>> uses narrow version and another which uses wide version. If each
>> library is used by several apps -- which is likely, and not all those
>> apps agree and narrow/wide question, you really need to install two
>> versions for each library.
>
> I don't understand what you are saying in the penultimate clause "and not
> all those apps agree and narrow/wide question". If an application uses
> both the narrow and wide versions of a library, then of course it will
> have to include both of them. My own experience is that most applications
> will use one or the other.

Probably we misunderstand each other because I have in mind Linux model of
application installation. Each application and each library is a separate
package. Typically, a library is used by several applications.

Now, I have a number of library packages. Say no application uses wide char
interface at the moment, so only narrow libraries are installed, Now, a
single application decides to use wide interface, so its package now
depends on wide libraries. As the result, I have to install, in addition to
some narrow libraries, their wide equivalents. After enough applications
decide to use Unicode, most libraries will have to be installed in two
flavours.

> I think C++ should have template specializations for all of its native
> character types in its standard libraries whenever a character is being
> used properly as a native character type type. Currently C++ has two
> native character types, 'char' and wchar_t'. In the future who knows
> whether ot not other native character types will be added, perhaps a
> specific Unicode type. Using templates, and having specializations of its
> native character types, makes it much easier for C++ to adapt other future
> character types as native character types.

I don't think this is very likely for new character types to appear.

> Even when other native
> character types are not added to C++, creating one's own implementations
> of character types is much easier when templates and specializations are
> used. We have this wonderful facility in the C++ language, templates. Not
> using it, because an application might have to use different character
> types and include more than one specialization, seems illogical to me.

I'm actually worried that when using templates in a straight-forward way,
all libraries will have to some in two variants or be twice larger, which
is bad because of:
- code size reasons,
- configurations reason (just one more configuration variant to worry about)
- interoperability/convenience? (what if I use unicode paths and want to
  pass narrow string to one of the operators?)

With a bit of additional design, it's possible to make library use one
representation internally, and have either non-templated interface, or a
tiny templated facade. E.g:

   boost::path p;
   p = p / L"foo" / "bar";

does not seem all that bad thing for me.

- Volodya


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net