[ Web Proxy ]
URL:
Viewing: http://ja.cppreference.com/cpp/string/basic_string/front [Back]  [Original]

std::basic_string<CharT,Traits,Allocator>::front - cppreference.com
cppreference.com

std::basic_string<CharT,Traits,Allocator>::front

: cppreference.com
 
C++
(C++20)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
 
 
std::basic_string
 
<tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody>
CharT& front();
(C++11)
(C++20)
constexpr CharT& front();
(C++20)
const CharT& front() const;
(C++11)
(C++20)
constexpr const CharT& front() const;
(C++20)

empty() == true

()

operator[](0)

#include <iostream>
#include <string>
 
int main()
{
  {
    std::string s("Exemplary");
    char& f = s.front();
    f = 'e';
    std::cout << s << '\n'; // "exemplary"
  }
 
  {
    std::string const c("Exemplary");
    char const& f = c.front();
    std::cout << &f << '\n'; // "Exemplary"
  }
}

:

exemplary
Exemplary

(C++11)

() [edit]

Web Proxy Viewer  |  New URL  |  Original Page