Hello All,
Is the following fragment well defined?
std::string some_str("Hello World");
....
some_str.replac e(some_str.find ("Wor"), strlen("Wor"), other_str);
Or does the nested call on the same string object invoke UB?
Regards,
Suman 3 1201
* Suman:
Hello All,
Is the following fragment well defined?
std::string some_str("Hello World");
...
some_str.replac e(some_str.find ("Wor"), strlen("Wor"), other_str);
Or does the nested call on the same string object invoke UB?
Arguments are evaluated before a function is called.
So, no UB on that account.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
On Tue, 10 Apr 2007 14:54:32 +0300, Suman <sk*****@gmail. comwrote:
Hello All,
Is the following fragment well defined?
std::string some_str("Hello World");
...
some_str.replac e(some_str.find ("Wor"), strlen("Wor"), other_str);
Or does the nested call on the same string object invoke UB?
Why should it? The nested call returns before replace() is called?
Boris
On Apr 10, 5:08 pm, Boris <b...@gtemail.n etwrote:
On Tue, 10 Apr 2007 14:54:32 +0300, Suman <skar...@gmail. comwrote:
....
...
some_str.replac e(some_str.find ("Wor"), strlen("Wor"), other_str);
Or does the nested call on the same string object invoke UB?
Why should it? The nested call returns before replace() is called?
I forgot about the 'argument evaluation before call' part.
Thank you all for your express responses.
Regards,
Suman This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Espen Ruud Schultz |
last post by:
Lets say I have a char pointer and an std::string. Is it possible to get a
pointer to the std::string's "content" so that the char pointer can point to
the same text? And vice versa; can I give the std::string a pointer and a
length and then give the std::string control over the pointer and its
content?
I'm basically trying to avoid...
|
by: Cheng Mo |
last post by:
Below code cannot be compiled.
try
{
throw std::string;
}
catch(...)
{
}
While below is correct.
|
by: lovecreatesbea... |
last post by:
Is it correct and safe to compare a string object with "", a pair of
quotation marks quoted empty string?If the string object: s = ""; does
s contain a single '\'? Is it better to use std::string::size or
std::string::empty to deal with this condition? Thank you.
string s = "";
if (s == "");
if (s.size == 0);
if (s.empty());
|
by: mathieu |
last post by:
Hi C++ gurus,
Why in the following code the std::string destructor is being called
before the 'catch' ?
Thanks,
-Mathieu
#include <iostream>
#include <sstream>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |