MCPcopy Index your code
hub / github.com/HelenOS/helenos / basic_string

Class basic_string

uspace/lib/cpp/include/__bits/string/string.hpp:441–1605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439
440 template<class Char, class Traits, class Allocator>
441 class basic_string
442 {
443 public:
444 using traits_type = Traits;
445 using value_type = typename traits_type::char_type;
446 using allocator_type = Allocator;
447 using size_type = typename allocator_traits<allocator_type>::size_type;
448 using difference_type = typename allocator_traits<allocator_type>::difference_type;
449
450 using reference = value_type&;
451 using const_reference = const value_type&;
452 using pointer = typename allocator_traits<allocator_type>::pointer;
453 using const_pointer = typename allocator_traits<allocator_type>::const_pointer;
454
455 using iterator = pointer;
456 using const_iterator = const_pointer;
457 using reverse_iterator = std::reverse_iterator<iterator>;
458 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
459
460 static constexpr size_type npos = -1;
461
462 /**
463 * 21.4.2, construct/copy/destroy:
464 * TODO: tagged constructor that moves the char*
465 * and use that with asprintf in to_string
466 */
467
468 basic_string() noexcept
469 : basic_string(allocator_type{})
470 { /* DUMMY BODY */ }
471
472 explicit basic_string(const allocator_type& alloc)
473 : data_{}, size_{}, capacity_{}, allocator_{alloc}
474 {
475 /**
476 * Postconditions:
477 * data() = non-null copyable value that can have 0 added to it.
478 * size() = 0
479 * capacity() = unspecified
480 */
481 data_ = allocator_.allocate(default_capacity_);
482 capacity_ = default_capacity_;
483 }
484
485 basic_string(const basic_string& other)
486 : data_{}, size_{other.size_}, capacity_{other.capacity_},
487 allocator_{other.allocator_}
488 {
489 init_(other.data(), size_);
490 }
491
492 basic_string(basic_string&& other)
493 : data_{other.data_}, size_{other.size_},
494 capacity_{other.capacity_}, allocator_{move(other.allocator_)}
495 {
496 other.data_ = nullptr;
497 other.size_ = 0;
498 other.capacity_ = 0;

Callers 1

compareMethod · 0.70

Calls 9

copyFunction · 0.85
beginFunction · 0.85
endFunction · 0.85
replaceFunction · 0.85
swapFunction · 0.70
beginMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
resize_without_copy_Method · 0.45

Tested by

no test coverage detected