1331:caa66055b025 | 1332:02946dc73e6a |
---|---|
261 } | 261 } |
262 cx_attr_nodiscard | 262 cx_attr_nodiscard |
263 static inline cxstring cx_strcast(cxstring str) { | 263 static inline cxstring cx_strcast(cxstring str) { |
264 return str; | 264 return str; |
265 } | 265 } |
266 cx_attr_nodiscard | |
267 static inline cxstring cx_strcast(const char *str) { | |
268 return cx_str(str); | |
269 } | |
266 extern "C" { | 270 extern "C" { |
267 #else | 271 #else |
268 /** | 272 /** |
269 * Internal function, do not use. | 273 * Internal function, do not use. |
270 * @param str | 274 * @param str |
282 * @see cx_strcast() | 286 * @see cx_strcast() |
283 */ | 287 */ |
284 cx_attr_nodiscard | 288 cx_attr_nodiscard |
285 static inline cxstring cx_strcast_c(cxstring str) { | 289 static inline cxstring cx_strcast_c(cxstring str) { |
286 return str; | 290 return str; |
291 } | |
292 | |
293 /** | |
294 * Internal function, do not use. | |
295 * @param str | |
296 * @return | |
297 * @see cx_strcast() | |
298 */ | |
299 cx_attr_nodiscard | |
300 static inline cxstring cx_strcast_z(const char *str) { | |
301 return cx_str(str); | |
287 } | 302 } |
288 | 303 |
289 /** | 304 /** |
290 * Casts a mutable string to an immutable string. | 305 * Casts a mutable string to an immutable string. |
291 * | 306 * |
298 * @param str (@c cxstring or @c cxmutstr) the string to cast | 313 * @param str (@c cxstring or @c cxmutstr) the string to cast |
299 * @return (@c cxstring) an immutable copy of the string pointer | 314 * @return (@c cxstring) an immutable copy of the string pointer |
300 */ | 315 */ |
301 #define cx_strcast(str) _Generic((str), \ | 316 #define cx_strcast(str) _Generic((str), \ |
302 cxmutstr: cx_strcast_m, \ | 317 cxmutstr: cx_strcast_m, \ |
303 cxstring: cx_strcast_c) \ | 318 cxstring: cx_strcast_c, \ |
304 (str) | 319 const char*: cx_strcast_z, \ |
320 char *: cx_strcast_z) (str) | |
305 #endif | 321 #endif |
306 | 322 |
307 /** | 323 /** |
308 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function. | 324 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function. |
309 * | 325 * |