Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ C ++ string in the end     - User rights management system under Linux (Linux)

- Linux system commands to view hardware information (Linux)

- CentOS 6.5 install VNC-Server (Linux)

- Android application simulates the phone keypad (Programming)

- Java implementation chain store binary search tree (recursive method) (Programming)

- Linux + Apache + PHP + Oracle based environment to build (Server)

- To install and use the Doxygen under Linux (Linux)

- Linux batch copy data script (Linux)

- Oracle how to assess the true concurrent session (Database)

- Oracle GoldenGate encryption (Database)

- Linux set the maximum number of open files nofile and nr_open, file-max Description (Linux)

- CoreOS quick installation to get started on a PC (Linux)

- CentOS 6.5_x64 install Oracle 11g R2 (Database)

- Turning off the interface eth0: error: Disconnect the device 'eth0' (Linux)

- Oracle Automatic Diagnostic Repository (Automatic Diagnostic Repository, ADR) (Database)

- Apache POI Excel Document Processing (Linux)

- Linux systems use logwatch log file monitoring (Linux)

- Ordinary users how the Linux system shutdown (Linux)

- Linux Security (Linux)

- MySQL Server Time Synchronization Problem (Database)

 
         
  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

statement:

template < class charT> struct char_traits;

effect:

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

statement:

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

effect:
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;
     
         
         
         
  More:      
 
- React Native (Programming)
- Linux system security check notes on performance (Linux)
- A command to install Sublime Text 3 on Manjaro / Archlinux (Linux)
- VMware clone Linux find eth0 (Linux)
- Docker knowledge base (Server)
- CentOS 5.8 (64) Python 2.7.5 installation error resolved (Linux)
- Puppet Detailed centralized configuration management system (Server)
- Install Java 8 on Ubuntu using PPA (Linux)
- Oracle archive log summary (Database)
- Shared directory settings between Linux and Linux (Linux)
- How to use Quagga BGP (Border Gateway Protocol) router to filter BGP routing (Linux)
- Android child thread really do not update UI (Programming)
- Linux Shell Scripting multithreading (Programming)
- Python configuration tortuous road of third-party libraries Numpy and matplotlib (Programming)
- Django1.8 return json json string and the string contents of the received post (Programming)
- Bash variable expansion modifier (Programming)
- Depth understanding of C language (Programming)
- Introduction to Linux system process monitoring tools (Linux)
- Linux iptables: basic principles and rules (Linux)
- Cool Android realization SVG animation (Programming)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.