Opened 6 years ago

Closed 5 years ago

#12776 closed Feature Requests (wontfix)

Add c_str free function to Boost::Format

Reported by: beojan@… Owned by: James E. King, III
Milestone: Boost 1.66.0 Component: format
Version: Boost 1.61.0 Severity: Optimization
Keywords: Cc:

Description

A c_str function that returns a pointer to a new copy of the formatted string would be useful to use Boost::Format to create C-style strings.

Simply calling str(fmt).c_str() is insufficient since this returns a pointer to a temporary.

Change History (3)

comment:1 by olafvdspek@…, 5 years ago

Where would this new copy be stored?

comment:2 by James E. King, III, 5 years ago

Owner: changed from Samuel Krempp to James E. King, III
Severity: ProblemOptimization

As a pattern in the standard template library that already exists, c_str() returns a pointer that is only valid for the lifetime of the object from which it was derived, and may be invalidated by mutations of that object. I see little value in encouraging the use of naked pointers here or in overriding the meaning of c_str.

comment:3 by James E. King, III, 5 years ago

Milestone: To Be DeterminedBoost 1.66.0
Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.