Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ C ++ string in the end     - MySQL in order by inaccurate results in problems and solutions (Database)

- Linux security-related basics (Linux)

- Additional SQL Server 5123 database reported error (Database)

- Spacewalk remove packages install the update (Linux)

- apt-get install openstack pkg Troubleshooting (Linux)

- RealVNC Server 5.2.3 Installation and Configuration In Fedora (Server)

- How to install with JSON support in Ubuntu 15.04 SQLite 3.9.1 (Database)

- Linux Learning Notes: Users and Groups (Linux)

- Java Foundation - The relationship between abstract classes and interfaces (Programming)

- How to use the DM-Crypt encryption Linux File System (Linux)

- 8 Git tips (Linux)

- Linux --- manual release system cache (Linux)

- CentOS-based Kickstart automated installation practice (Linux)

- Calculate CPU utilization (Linux)

- How to Install Apache on Linux servers (Server)

- Oracle archive log deletion (Database)

- Java inner classes (Programming)

- Linux directory structure (Linux)

- MySQL innodb_table_stats table does not exist solution (Database)

- Django 1.8 TEMPLATE_DIRS configuration and STATICFILES_DIRS (Server)

  C ++ string in the end
  Add Date : 2018-11-21      
  C ++ string in the end is what?

To answer this question, one should first understand what is basic_string.
Look basic_string statement:

template < class charT, // type definition characters in a string
          class traits = char_traits < charT>, // basic_string :: traits_type
          class Alloc = allocator < charT> // basic_string :: allocator_type
          > Class basic_string;

Visible, basic_string class is essentially a template.
Then explain a little more detail:

1. About char_traits


template < class charT> struct char_traits;


Character traits classes specify character properties and provide specific semantics for certain operations on characters and sequences of characters. (From C ++ Referencce, address: http: //www.cplusplus.com/reference/string/char_traits/)

That is: it specifies the attribute of the character, and provides specific semantic role in the characters or character sequences of certain operations.

2. About allocator


template < class T> class allocator; // at < memory> header file allocator: Splitter

Allocators are classes that define memory models to be used by some parts of the Standard Library, and most specifically, by STL containers (from C ++ Referencce, address:. Http: //www.cplusplus.com/reference/memory/allocator/? kw = allocator)
That is: It defines part of the standard library is used, in particular STL memory model.

Now let's string declaration:

typedef basic_string < char, char_traits < char>, allocator < char >> string;

Now, we understand, the original is such a thing:

With basic types char instantiate the class template basic_string, to give a specific template class, then, is it typedef string.

In other words, is essentially a template class string is basic_string < char, char_traits < char>, allocator < char >>, string is the corresponding "short." Intuitively understand, string instance of the object (that is string str; the str) is a char sequence, but unlike char * str, stingr str with many good package for their own operations.

ps: basic_string there are other examples, such as:

typedef basic_string < wchar_t, char_traits < wchar_t>, allocator < wchar_t >> wstring;
- Service manager OpenBSD on rccl (Server)
- How to upgrade to Oracle 11g Oracle 12c (Database)
- Storm basic framework for analysis (Programming)
- Restore database fault encountered ORA-0600 (Database)
- Java to create a table in the database SYBase (Database)
- Struts2 Result Types (Programming)
- To install Redis under Linux (Database)
- CentOS 6.5 dual card configuration, one of the external network, a local area network connection (Linux)
- OpenCV cvFindCornerSubPix () to find sub-pixel Corner (Programming)
- KUbuntu / Ubuntu 14.04 (downgrade) installed SVN 1.7 (Linux)
- osprofiler use OpenStack Cinder Lane (Server)
- To install file manager Nautilus 3.12.2 under ubuntu (Linux)
- GitLab Installation Guide -Ubuntu 14.04 LTS (Server)
- Compression software on a simple comparison of zip and gz (Linux)
- Detailed use Zabbix monitoring Nginx (Server)
- Binary tree traversal algorithm summary (recursive and non-recursive) (Programming)
- Subsequent binary search tree traversal sequence (Programming)
- Java regular expressions examples (Programming)
- EXP-00091 Error resolved (Database)
- Hard disk encryption to protect data security (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.