Commit 84d15a30 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2129 from Alexhuszagh/master

Patch to add front() and back(), as per issue #2123.
parents dbecc779 f9702604
...@@ -63,6 +63,8 @@ cdef extern from "<string>" namespace "std" nogil: ...@@ -63,6 +63,8 @@ cdef extern from "<string>" namespace "std" nogil:
char& at(size_t) char& at(size_t)
char& operator[](size_t) char& operator[](size_t)
char& front()
char& back()
int compare(const string&) int compare(const string&)
string& append(const string&) string& append(const string&)
......
# mode: run
# tag: cpp, werror, cpp11
# distutils: extra_compile_args=-std=c++11
from libcpp.string cimport string
b_asdf = b'asdf'
def test_element_access(char *py_str):
"""
>>> test_element_access(b_asdf)
('a', 'f')
"""
cdef string s
s = string(py_str)
return chr(s.front()), chr(s.back())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment