Skip to content

P1032R1 Misc constexpr bits #2495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions source/containers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@
for some types of containers but not others. Those containers for which the
listed operations are provided shall implement the semantics described in
\tref{containers.optional.operations} unless otherwise stated.
If the iterators passed to \tcode{lexicographical_compare}
satisfy the constexpr iterator requirements\iref{iterator.requirements.general}
then the operations described in \tref{containers.optional.operations}
are implemented by constexpr functions.

\begin{libreqtab5}
{Optional container operations}
Expand Down Expand Up @@ -3009,7 +3013,7 @@
template<class T, size_t N>
constexpr bool operator>=(const array<T, N>& x, const array<T, N>& y);
template<class T, size_t N>
void swap(array<T, N>& x, array<T, N>& y) noexcept(noexcept(x.swap(y)));
constexpr void swap(array<T, N>& x, array<T, N>& y) noexcept(noexcept(x.swap(y)));

template<class T> class tuple_size;
template<size_t I, class T> class tuple_element;
Expand Down Expand Up @@ -3235,8 +3239,8 @@

// no explicit construct/copy/destroy for aggregate type

void fill(const T& u);
void swap(array&) noexcept(is_nothrow_swappable_v<T>);
constexpr void fill(const T& u);
constexpr void swap(array&) noexcept(is_nothrow_swappable_v<T>);

// iterators
constexpr iterator begin() noexcept;
Expand Down Expand Up @@ -3326,7 +3330,7 @@

\indexlibrarymember{array}{fill}%
\begin{itemdecl}
void fill(const T& u);
constexpr void fill(const T& u);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -3336,7 +3340,7 @@

\indexlibrarymember{array}{swap}%
\begin{itemdecl}
void swap(array& y) noexcept(is_nothrow_swappable_v<T>);
constexpr void swap(array& y) noexcept(is_nothrow_swappable_v<T>);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -3356,7 +3360,7 @@
\indexlibrarymember{array}{swap}%
\begin{itemdecl}
template<class T, size_t N>
void swap(array<T, N>& x, array<T, N>& y) noexcept(noexcept(x.swap(y)));
constexpr void swap(array<T, N>& x, array<T, N>& y) noexcept(noexcept(x.swap(y)));
\end{itemdecl}

\begin{itemdescr}
Expand Down
93 changes: 48 additions & 45 deletions source/iterators.tex
Original file line number Diff line number Diff line change
Expand Up @@ -768,15 +768,16 @@

template<class Container> class back_insert_iterator;
template<class Container>
back_insert_iterator<Container> back_inserter(Container& x);
constexpr back_insert_iterator<Container> back_inserter(Container& x);

template<class Container> class front_insert_iterator;
template<class Container>
front_insert_iterator<Container> front_inserter(Container& x);
constexpr front_insert_iterator<Container> front_inserter(Container& x);

template<class Container> class insert_iterator;
template<class Container>
insert_iterator<Container> inserter(Container& x, typename Container::iterator i);
constexpr insert_iterator<Container>
inserter(Container& x, typename Container::iterator i);

template<class Iterator> class move_iterator;
template<class Iterator1, class Iterator2>
Expand Down Expand Up @@ -1704,25 +1705,25 @@
using reference = void;
using container_type = Container;

explicit back_insert_iterator(Container& x);
back_insert_iterator& operator=(const typename Container::value_type& value);
back_insert_iterator& operator=(typename Container::value_type&& value);
constexpr explicit back_insert_iterator(Container& x);
constexpr back_insert_iterator& operator=(const typename Container::value_type& value);
constexpr back_insert_iterator& operator=(typename Container::value_type&& value);

back_insert_iterator& operator*();
back_insert_iterator& operator++();
back_insert_iterator operator++(int);
constexpr back_insert_iterator& operator*();
constexpr back_insert_iterator& operator++();
constexpr back_insert_iterator operator++(int);
};

template<class Container>
back_insert_iterator<Container> back_inserter(Container& x);
constexpr back_insert_iterator<Container> back_inserter(Container& x);
}
\end{codeblock}

\rSec4[back.insert.iter.ops]{Operations}

\indexlibrary{\idxcode{back_insert_iterator}!constructor}%
\begin{itemdecl}
explicit back_insert_iterator(Container& x);
constexpr explicit back_insert_iterator(Container& x);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1735,7 +1736,7 @@

\indexlibrarymember{operator=}{back_insert_iterator}%
\begin{itemdecl}
back_insert_iterator& operator=(const typename Container::value_type& value);
constexpr back_insert_iterator& operator=(const typename Container::value_type& value);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1750,7 +1751,7 @@

\indexlibrarymember{operator=}{back_insert_iterator}%
\begin{itemdecl}
back_insert_iterator& operator=(typename Container::value_type&& value);
constexpr back_insert_iterator& operator=(typename Container::value_type&& value);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1765,7 +1766,7 @@

\indexlibrarymember{operator*}{back_insert_iterator}%
\begin{itemdecl}
back_insert_iterator& operator*();
constexpr back_insert_iterator& operator*();
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1776,8 +1777,8 @@

\indexlibrarymember{operator++}{back_insert_iterator}%
\begin{itemdecl}
back_insert_iterator& operator++();
back_insert_iterator operator++(int);
constexpr back_insert_iterator& operator++();
constexpr back_insert_iterator operator++(int);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1791,7 +1792,7 @@
\indexlibrary{\idxcode{back_inserter}}%
\begin{itemdecl}
template<class Container>
back_insert_iterator<Container> back_inserter(Container& x);
constexpr back_insert_iterator<Container> back_inserter(Container& x);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1818,25 +1819,25 @@
using reference = void;
using container_type = Container;

explicit front_insert_iterator(Container& x);
front_insert_iterator& operator=(const typename Container::value_type& value);
front_insert_iterator& operator=(typename Container::value_type&& value);
constexpr explicit front_insert_iterator(Container& x);
constexpr front_insert_iterator& operator=(const typename Container::value_type& value);
constexpr front_insert_iterator& operator=(typename Container::value_type&& value);

front_insert_iterator& operator*();
front_insert_iterator& operator++();
front_insert_iterator operator++(int);
constexpr front_insert_iterator& operator*();
constexpr front_insert_iterator& operator++();
constexpr front_insert_iterator operator++(int);
};

template<class Container>
front_insert_iterator<Container> front_inserter(Container& x);
constexpr front_insert_iterator<Container> front_inserter(Container& x);
}
\end{codeblock}

\rSec4[front.insert.iter.ops]{Operations}

\indexlibrary{\idxcode{front_insert_iterator}!constructor}%
\begin{itemdecl}
explicit front_insert_iterator(Container& x);
constexpr explicit front_insert_iterator(Container& x);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1849,7 +1850,7 @@

\indexlibrarymember{operator=}{front_insert_iterator}%
\begin{itemdecl}
front_insert_iterator& operator=(const typename Container::value_type& value);
constexpr front_insert_iterator& operator=(const typename Container::value_type& value);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1864,7 +1865,7 @@

\indexlibrarymember{operator=}{front_insert_iterator}%
\begin{itemdecl}
front_insert_iterator& operator=(typename Container::value_type&& value);
constexpr front_insert_iterator& operator=(typename Container::value_type&& value);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1879,7 +1880,7 @@

\indexlibrarymember{operator*}{front_insert_iterator}%
\begin{itemdecl}
front_insert_iterator& operator*();
constexpr front_insert_iterator& operator*();
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1890,8 +1891,8 @@

\indexlibrarymember{operator++}{front_insert_iterator}%
\begin{itemdecl}
front_insert_iterator& operator++();
front_insert_iterator operator++(int);
constexpr front_insert_iterator& operator++();
constexpr front_insert_iterator operator++(int);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1905,7 +1906,7 @@
\indexlibrary{\idxcode{front_inserter}}%
\begin{itemdecl}
template<class Container>
front_insert_iterator<Container> front_inserter(Container& x);
constexpr front_insert_iterator<Container> front_inserter(Container& x);
\end{itemdecl}

\begin{itemdescr}
Expand Down Expand Up @@ -1933,25 +1934,26 @@
using reference = void;
using container_type = Container;

insert_iterator(Container& x, typename Container::iterator i);
insert_iterator& operator=(const typename Container::value_type& value);
insert_iterator& operator=(typename Container::value_type&& value);
constexpr insert_iterator(Container& x, typename Container::iterator i);
constexpr insert_iterator& operator=(const typename Container::value_type& value);
constexpr insert_iterator& operator=(typename Container::value_type&& value);

insert_iterator& operator*();
insert_iterator& operator++();
insert_iterator& operator++(int);
constexpr insert_iterator& operator*();
constexpr insert_iterator& operator++();
constexpr insert_iterator& operator++(int);
};

template<class Container>
insert_iterator<Container> inserter(Container& x, typename Container::iterator i);
constexpr insert_iterator<Container>
inserter(Container& x, typename Container::iterator i);
}
\end{codeblock}

\rSec4[insert.iter.ops]{Operations}

\indexlibrary{\idxcode{insert_iterator}!constructor}%
\begin{itemdecl}
insert_iterator(Container& x, typename Container::iterator i);
constexpr insert_iterator(Container& x, typename Container::iterator i);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1966,7 +1968,7 @@

\indexlibrarymember{operator=}{insert_iterator}%
\begin{itemdecl}
insert_iterator& operator=(const typename Container::value_type& value);
constexpr insert_iterator& operator=(const typename Container::value_type& value);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -1985,7 +1987,7 @@

\indexlibrarymember{operator=}{insert_iterator}%
\begin{itemdecl}
insert_iterator& operator=(typename Container::value_type&& value);
constexpr insert_iterator& operator=(typename Container::value_type&& value);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -2004,7 +2006,7 @@

\indexlibrarymember{operator*}{insert_iterator}%
\begin{itemdecl}
insert_iterator& operator*();
constexpr insert_iterator& operator*();
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -2015,8 +2017,8 @@

\indexlibrarymember{operator++}{insert_iterator}%
\begin{itemdecl}
insert_iterator& operator++();
insert_iterator& operator++(int);
constexpr insert_iterator& operator++();
constexpr insert_iterator& operator++(int);
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -2030,7 +2032,8 @@
\indexlibrary{\idxcode{inserter}}%
\begin{itemdecl}
template<class Container>
insert_iterator<Container> inserter(Container& x, typename Container::iterator i);
constexpr insert_iterator<Container>
inserter(Container& x, typename Container::iterator i);
\end{itemdecl}

\begin{itemdescr}
Expand Down
28 changes: 14 additions & 14 deletions source/strings.tex
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@
static constexpr size_t length(const char_type* s);
static constexpr const char_type* find(const char_type* s, size_t n,
const char_type& a);
static char_type* move(char_type* s1, const char_type* s2, size_t n);
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
static char_type* assign(char_type* s, size_t n, char_type a);
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
static constexpr char_type* assign(char_type* s, size_t n, char_type a);

static constexpr int_type not_eof(int_type c) noexcept;
static constexpr char_type to_char_type(int_type c) noexcept;
Expand Down Expand Up @@ -457,9 +457,9 @@
static constexpr size_t length(const char_type* s);
static constexpr const char_type* find(const char_type* s, size_t n,
const char_type& a);
static char_type* move(char_type* s1, const char_type* s2, size_t n);
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
static char_type* assign(char_type* s, size_t n, char_type a);
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
static constexpr char_type* assign(char_type* s, size_t n, char_type a);

static constexpr int_type not_eof(int_type c) noexcept;
static constexpr char_type to_char_type(int_type c) noexcept;
Expand Down Expand Up @@ -507,9 +507,9 @@
static constexpr size_t length(const char_type* s);
static constexpr const char_type* find(const char_type* s, size_t n,
const char_type& a);
static char_type* move(char_type* s1, const char_type* s2, size_t n);
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
static char_type* assign(char_type* s, size_t n, char_type a);
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
static constexpr char_type* assign(char_type* s, size_t n, char_type a);

static constexpr int_type not_eof(int_type c) noexcept;
static constexpr char_type to_char_type(int_type c) noexcept;
Expand Down Expand Up @@ -557,9 +557,9 @@
static constexpr size_t length(const char_type* s);
static constexpr const char_type* find(const char_type* s, size_t n,
const char_type& a);
static char_type* move(char_type* s1, const char_type* s2, size_t n);
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
static char_type* assign(char_type* s, size_t n, char_type a);
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
static constexpr char_type* assign(char_type* s, size_t n, char_type a);

static constexpr int_type not_eof(int_type c) noexcept;
static constexpr char_type to_char_type(int_type c) noexcept;
Expand Down Expand Up @@ -4997,7 +4997,7 @@
constexpr void swap(basic_string_view& s) noexcept;

// \ref{string.view.ops}, string operations
size_type copy(charT* s, size_type n, size_type pos = 0) const;
constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;

constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;

Expand Down Expand Up @@ -5392,7 +5392,7 @@

\indexlibrarymember{copy}{basic_string_view}%
\begin{itemdecl}
size_type copy(charT* s, size_type n, size_type pos = 0) const;
constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
\end{itemdecl}

\begin{itemdescr}
Expand Down
Loading