473,805 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does anyone has already seen a non mutable String based on std::string

Hi,

I am currently implementing some basic classes from .NET into modern C++.
And I would like to know if someone would know a non mutable string class.
May 28 '06
12 3157
On 28 May 2006 10:57:50 -0700, "kwikius" >You might want to look at
The most popular downloads in the Boost
Vault, where fixed_string was most popular download:

http://tinyurl.com/rstoa

Note that the version there was reviewed but not accepted:

http://www.boost.org/more/formal_review_schedule.html
Grande confusione! boost::fixed_st ring is not an immutable string
class/template. The mentioned Boost library is boost::const_st ring<>
(which, of course, is not an accepted Boost library ;-).
The reasons were IIRC that the implementation had moved away from the
expected concept of a fixed string and so wasnt what potential users
were looking for. However the large amount of downloads suggests that
there is a lot of interest in this functionality. I havent looked at
your version in detail but from looking at the intro, it looks like it
might be worth posting a link to it on the boost developers list to see
whether there is interest. I think there might be.


Thank you for considering my code 'boost-able' but my goal was exactly
the opposite. 'fix_str' consists of very lightweight classes (not
templates, no traits and policies involved) with specified performance
characteristics for copying, assignment and default construction
(unlike std::string).

Best regards,
Roland Pibinger
May 28 '06 #11
On Sun, 28 May 2006 20:58:48 +0200, "Alf P. Steinbach"
<al***@start.no > wrote:
An immutable string class is different from 'std::string const' in that
its operations do not carry the overhead associated with mutability, and
that it supports assignment and thus can be used in standard containers.

Functionalit y-wise it is similar to

typedef boost::shared_p tr<std::string const> ValueString;


Actually, that should be avoided! Immutable objects make only sense as
immutable value objects. In C++ (not in Java) 'value object' means
that an assignment replaces (=mutates) the original object, not just a
reference to it. A totally immutable value object would not be very
useful in C++ (e.g. you could not assign a return value). I asked some
time ago for a name for 'assignable-but-otherwise-immutable-objects'.
The concept seems to be known but there is no established name for it.

http://groups.google.com/group/comp....1ef8b7634c0dc7

Best regards,
Roland Pibinger
May 28 '06 #12
Roland Pibinger wrote:
Thank you for considering my code 'boost-able' but my goal was exactly
the opposite.
The opposite of boost-able... ? Would that be unboost-able. Is this a
deliberate aim? :-)
'fix_str' consists of very lightweight classes (not
templates, no traits and policies involved) with specified performance
characteristics for copying, assignment and default construction
(unlike std::string).


AFAIK http://www.boost.org has no requirement that a candidate library
uses templates, traits or policies.

regrads
Andy Little

May 29 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
8199
by: Angus Leeming | last post by:
Hello, Could someone explain to me why the Standard conveners chose to typedef std::string rather than derive it from std::basic_string<char, ...>? The result of course is that it is effectively impossible to forward declare std::string. (Yes I am aware that some libraries have a string_fwd.h header, but this is not portable.) That said, is there any real reason why I can't derive an otherwise empty
2
3096
by: Vyacheslav Kononenko | last post by:
All, If I am not mistaken I had some problems with code like this: std::string foo, bar; .... somefunc( foo.c_str(), bar.c_str() ); Problem was that c_str() used buffer shared btw instances of std::string in that implementation. I did not find anything that
9
3303
by: Jim Langston | last post by:
#include <string> int main () { std::string MyString = "Testing"; MyString = " " + MyString; } This works in Microsoft Visual C++ .net 2003
1
3760
by: Maxwell | last post by:
Hello, I having having oodles of trouble using the std lib in my MC++ (VS.NET 2003) Class library. I figured out a simple sample to reproduce the errors I am having. Create a MC++ (VS.NET 2003) class library and type in the following code below: #include <map> #include<string>
9
3792
by: Fei Liu | last post by:
In Accellerated C++, the author recommends that in a header file one should not declare using std::string, using std::vector etc instead one should directly specify the namespace specifier in code. for example, this is bad practice: header.h #include <string> using std::string;
2
9230
by: suman.nandan | last post by:
Hi Experts, In the following code (sorry for using C printf in the code !) : ---------------------------------------------- #include <string> #include<cstdio> using namespace std; int main () {
7
2439
by: Adrian | last post by:
Why does std::strings find search from the begining of the string when pos >= (std::string::npos-3) I cant find anything in the standard that says what find should do if pos==npos in find I tried it on a few platforms (all with gcc unfortunaley) and its seems to be consistent. Adrian
11
4294
by: Christopher Pisz | last post by:
Is std::string::npos always going to be less than any std::string 's size()? I am trying to handle a replacement of all occurances of a substr, in which the replacement also contains the substr. Yick. All I could come up with is: #include <string> int main() { std::string text;
12
12453
by: sas | last post by:
hi, i need that because the path functions for windows, like PathAppend and PathRemoveFileExt accept a writable zero terminated char*, but i didn't find that for std::string, with CString, i usually use GetBuffer for that LPTSTR CString::GetBuffer( int nMinBufLength )
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5541
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.