Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ C ++ string in the end     - Linux file system structure Introduction (Linux)

- Paint with Vim (Linux)

- Java multi-threaded communications pipeline flow (Programming)

- secureCRT remote login Linux must first open the connection protocol (Linux)

- Based kubernetes Construction Docker Cluster Management Comments (Server)

- Redis is installed and set up Ubuntu 14.04 from the environment under the main ssdb (Server)

- Oracle Database High-Risk Vulnerability Warning (Database)

- Oracle SDE and maintain common commands - Display space (Database)

- High-performance JavaScript reflows and repaints (Programming)

- MongoDB3.0.6 wiredtiger MMAPv1 (Database)

- Oracle database file path changes (Database)

- Variables Python variables (Programming)

- HTTP and HTTPS request response process difference (Linux)

- Using iptables achieve NAT (Linux)

- RabbitMQ tutorial examples: the Hello RabbitMQ World Java realization (Linux)

- Heartbeat (v1, v2, pacemaker) cluster components Overview (Server)

- Eclipse Android development environment installation (Linux)

- grep command Series: How to Use the grep command in Linux / UNIX (Linux)

- Java development environment to build under Ubuntu (Linux)

- After installing minimize RHEL / CentOS 7 we need to do (Linux)

  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;
- Using 30 seconds to write a detailed analysis of garbage removal system (Linux)
- Top command: the Task Manager under linux (Linux)
- Ubuntu development Nodejs (Linux)
- Java environment to build a number of issues (Linux)
- Linux install deploy Ansible (Linux)
- ORA-00600 error solve one case (Database)
- Linux common commands: nslookup, ls md5sum, uname, history, etc. (Linux)
- Use Docker / LXC quickly launch a desktop system (Linux)
- The istgt PSD on ported to Mac OS X (Linux)
- Installation and management of Linux applications (Linux)
- Linux, Chrome browser font settings beautification (Linux)
- Learning C language pointer essays (Programming)
- How to run Kali Linux 2.0 in Docker container (Linux)
- Standard and IO redirection (Linux)
- Linux non-graphical interface to install Oracle Database (Database)
- Memcache explain in detail (Server)
- How to install PlayOnLinux 4.2.5 under Ubuntu 14.04 / 12.04 (Linux)
- Yii PHP Framework Getting Started tutorial (Linux)
- Build your own Web server under Ubuntu Linux system (Server)
- Switching Virtual Machine + Ubuntu graphical interface and terminal interface (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.