struct A {
static constexpr int n = 5; // definition (declaration in C++ 2014)
};
constexpr int A::n; // redundant declaration (definition in C++ 2014)
— end example#include <complex> #include <cmath>
<assert.h> | <inttypes.h> | <signal.h> | <stdio.h> | <wchar.h> |
<complex.h> | <iso646.h> | <stdalign.h> | <stdlib.h> | <wctype.h> |
<ctype.h> | <limits.h> | <stdarg.h> | <string.h> | |
<errno.h> | <locale.h> | <stdbool.h> | <tgmath.h> | |
<fenv.h> | <math.h> | <stddef.h> | <time.h> | |
<float.h> | <setjmp.h> | <stdint.h> | <uchar.h> |
namespace std {
class strstreambuf : public basic_streambuf<char> {
public:
explicit strstreambuf(streamsize alsize_arg = 0);
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
strstreambuf(const char* gnext_arg, streamsize n);
strstreambuf(signed char* gnext_arg, streamsize n,
signed char* pbeg_arg = 0);
strstreambuf(const signed char* gnext_arg, streamsize n);
strstreambuf(unsigned char* gnext_arg, streamsize n,
unsigned char* pbeg_arg = 0);
strstreambuf(const unsigned char* gnext_arg, streamsize n);
virtual ~strstreambuf();
void freeze(bool freezefl = true);
char* str();
int pcount();
protected:
int_type overflow (int_type c = EOF) override;
int_type pbackfail(int_type c = EOF) override;
int_type underflow() override;
pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out) override;
pos_type seekpos(pos_type sp,
ios_base::openmode which
= ios_base::in | ios_base::out) override;
streambuf* setbuf(char* s, streamsize n) override;
private:
using strstate = T1; // exposition only
static const strstate allocated; // exposition only
static const strstate constant; // exposition only
static const strstate dynamic; // exposition only
static const strstate frozen; // exposition only
strstate strmode; // exposition only
streamsize alsize; // exposition only
void* (*palloc)(size_t); // exposition only
void (*pfree)(void*); // exposition only
};
}explicit strstreambuf(streamsize alsize_arg = 0);
Element | Value |
strmode | dynamic |
alsize | alsize_arg |
palloc | a null pointer |
pfree | a null pointer |
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
Element | Value |
strmode | dynamic |
alsize | an unspecified value |
palloc | palloc_arg |
pfree | pfree_arg |
strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
strstreambuf(signed char* gnext_arg, streamsize n,
signed char* pbeg_arg = 0);
strstreambuf(unsigned char* gnext_arg, streamsize n,
unsigned char* pbeg_arg = 0);
Element | Value |
strmode | 0 |
alsize | an unspecified value |
palloc | a null pointer |
pfree | a null pointer |
setg(gnext_arg, gnext_arg, pbeg_arg); setp(pbeg_arg, pbeg_arg + N);
strstreambuf(const char* gnext_arg, streamsize n);
strstreambuf(const signed char* gnext_arg, streamsize n);
strstreambuf(const unsigned char* gnext_arg, streamsize n);
virtual ~strstreambuf();
void freeze(bool freezefl = true);
char* str();
int pcount() const;
int_type overflow(int_type c = EOF) override;
int_type pbackfail(int_type c = EOF) override;
int_type underflow() override;
pos_type seekoff(off_type off, seekdir way, openmode which = in | out) override;
Conditions | Result |
(which & ios::in) != 0 | positions the input sequence |
(which & ios::out) != 0 | positions the output sequence |
(which & (ios::in | ios::out)) == (ios::in | ios::out)) and way == either ios::beg or ios::end | positions both the input and the output sequences |
Otherwise | the positioning operation fails. |
pos_type seekpos(pos_type sp, ios_base::openmode which
= ios_base::in | ios_base::out) override;
streambuf<char>* setbuf(char* s, streamsize n) override;
namespace std {
class istrstream : public basic_istream<char> {
public:
explicit istrstream(const char* s);
explicit istrstream(char* s);
istrstream(const char* s, streamsize n);
istrstream(char* s, streamsize n);
virtual ~istrstream();
strstreambuf* rdbuf() const;
char* str();
private:
strstreambuf sb; // exposition only
};
}explicit istrstream(const char* s);
explicit istrstream(char* s);
istrstream(const char* s, streamsize n);
istrstream(char* s, streamsize n);
namespace std {
class ostrstream : public basic_ostream<char> {
public:
ostrstream();
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
virtual ~ostrstream();
strstreambuf* rdbuf() const;
void freeze(bool freezefl = true);
char* str();
int pcount() const;
private:
strstreambuf sb; // exposition only
};
}ostrstream();
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
namespace std {
class strstream
: public basic_iostream<char> {
public:
// Types
using char_type = char;
using int_type = char_traits<char>::int_type;
using pos_type = char_traits<char>::pos_type;
using off_type = char_traits<char>::off_type;
// constructors/destructor
strstream();
strstream(char* s, int n,
ios_base::openmode mode = ios_base::in|ios_base::out);
virtual ~strstream();
// Members:
strstreambuf* rdbuf() const;
void freeze(bool freezefl = true);
int pcount() const;
char* str();
private:
strstreambuf sb; // exposition only
};
}strstream();
strstream(char* s, int n,
ios_base::openmode mode = ios_base::in|ios_base::out);
bool uncaught_exception() noexcept;
namespace std {
template<class T> struct owner_less<shared_ptr<T>> {
using result_type = bool;
using first_argument_type = shared_ptr<T>;
using second_argument_type = shared_ptr<T>;
};
template<class T> struct owner_less<weak_ptr<T>> {
using result_type = bool;
using first_argument_type = weak_ptr<T>;
using second_argument_type = weak_ptr<T>;
};
template <class T> class reference_wrapper {
public :
using result_type = see below; // not always defined
using argument_type = see below; // not always defined
using first_argument_type = see below; // not always defined
using second_argument_type = see below; // not always defined
};
template <class T> struct plus {
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
};
template <class T> struct minus {
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
};
template <class T> struct multiplies {
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
};
template <class T> struct divides {
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
};
template <class T> struct modulus {
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
};
template <class T> struct negate {
using argument_type = T;
using result_type = T;
};
template <class T> struct equal_to {
using first_argument_type = T;
using second_argument_type = T;
using result_type = bool;
};
template <class T> struct not_equal_to {
using first_argument_type = T;
using second_argument_type = T;
using result_type = bool;
};
template <class T> struct greater {
using first_argument_type = T;
using second_argument_type = T;
using result_type = bool;
};
template <class T> struct less {
using first_argument_type = T;
using second_argument_type = T;
using result_type = bool;
};
template <class T> struct greater_equal {
using first_argument_type = T;
using second_argument_type = T;
using result_type = bool;
};
template <class T> struct less_equal {
using first_argument_type = T;
using second_argument_type = T;
using result_type = bool;
};
template <class T> struct logical_and {
using first_argument_type = T;
using second_argument_type = T;
using result_type = bool;
};
template <class T> struct logical_or {
using first_argument_type = T;
using second_argument_type = T;
using result_type = bool;
};
template <class T> struct logical_not {
using argument_type = T;
using result_type = bool;
};
template <class T> struct bit_and {
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
};
template <class T> struct bit_or {
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
};
template <class T> struct bit_xor {
using first_argument_type = T;
using second_argument_type = T;
using result_type = T;
};
template <class T> struct bit_not {
using argument_type = T;
using result_type = T;
};
template<class R, class T1>
class function<R(T1)> {
public:
using argument_type = T1;
};
template<class R, class T1, class T2>
class function<R(T1, T2)> {
public:
using first_argument_type = T1;
using second_argument_type = T2;
};
}
namespace std {
template <class Key, class T, class Compare, class Allocator>
class map<Key, T, Compare, Allocator>::value_compare {
public:
using result_type = bool;
using first_argument_type = value_type;
using second_argument_type = value_type;
};
template <class Key, class T, class Compare, class Allocator>
class multimap<Key, T, Compare, Allocator>::value_compare {
public:
using result_type = bool;
using first_argument_type = value_type;
using second_argument_type = value_type;
};
}
namespace std {
template <class Predicate> class unary_negate;
template <class Predicate>
constexpr unary_negate<Predicate> not1(const Predicate&);
template <class Predicate> class binary_negate;
template <class Predicate>
constexpr binary_negate<Predicate> not2(const Predicate&);
}
template <class Predicate>
class unary_negate {
public:
constexpr explicit unary_negate(const Predicate& pred);
constexpr bool operator()(const typename Predicate::argument_type& x) const;
using argument_type = typename Predicate::argument_type;
using result_type = bool;
};constexpr bool operator()(const typename Predicate::argument_type& x) const;
template <class Predicate>
constexpr unary_negate<Predicate> not1(const Predicate& pred);
template <class Predicate>
class binary_negate {
public:
constexpr explicit binary_negate(const Predicate& pred);
constexpr bool operator()(const typename Predicate::first_argument_type& x,
const typename Predicate::second_argument_type& y) const;
using first_argument_type = typename Predicate::first_argument_type;
using second_argument_type = typename Predicate::second_argument_type;
using result_type = bool;
};constexpr bool operator()(const typename Predicate::first_argument_type& x,
const typename Predicate::second_argument_type& y) const;
template <class Predicate>
constexpr binary_negate<Predicate> not2(const Predicate& pred);
namespace std {
// specialize for void:
template <> class allocator<void> {
public:
using value_type = void;
using pointer = void*;
using const_pointer = const void*;
// reference-to-void members are impossible.
template <class U> struct rebind { using other = allocator<U>; };
};
template <class T> class allocator {
public:
using size_type = size_t;
using difference_type = ptrdiff_t;
using pointer = T*;
using const_pointer = const T*;
using reference = T&;
using const_reference = const T&;
template <class U> struct rebind { using other = allocator<U>; };
T* address(T& x) const noexcept;
const T* address(const T& x) const noexcept;
T* allocate(size_t n, const void* hint);
template<class U, class... Args>
void construct(U* p, Args&&... args);
template <class U>
void destroy(U* p);
size_t max_size() const noexcept;
};
}T* address(T& x) const noexcept;
const T* address(const T& x) const noexcept;
T* allocate(size_t n, const void* hint);
template <class U, class... Args>
void construct(U* p, Args&&... args);
template <class U>
void destroy(U* p);
size_t max_size() const noexcept;
namespace std {
template <class OutputIterator, class T>
class raw_storage_iterator {
public:
using iterator_category = output_iterator_tag;
using value_type = void;
using difference_type = void;
using pointer = void;
using reference = void;
explicit raw_storage_iterator(OutputIterator x);
raw_storage_iterator& operator*();
raw_storage_iterator& operator=(const T& element);
raw_storage_iterator& operator=(T&& element);
raw_storage_iterator& operator++();
raw_storage_iterator operator++(int);
OutputIterator base() const;
};
}explicit raw_storage_iterator(OutputIterator x);
raw_storage_iterator& operator*();
raw_storage_iterator& operator=(const T& element);
raw_storage_iterator& operator=(T&& element);
raw_storage_iterator& operator++();
raw_storage_iterator operator++(int);
OutputIterator base() const;
namespace std {
template <class T>
pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
template <class T>
void return_temporary_buffer(T* p);
} template <class T>
pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
template <class T> void return_temporary_buffer(T* p);
namespace std {
template <class T> struct is_literal_type;
template <class T> constexpr bool is_literal_type_v = is_literal_type<T>::value;
template <class> struct result_of; // not defined
template <class Fn, class... ArgTypes> struct result_of<Fn(ArgTypes...)>;
template <class T> using result_of_t = typename result_of<T>::type;
}
namespace std {
template<class Category, class T, class Distance = ptrdiff_t,
class Pointer = T*, class Reference = T&>
struct iterator {
using iterator_category = Category;
using value_type = T;
using difference_type = Distance;
using pointer = Pointer;
using reference = Reference;
};
}
class MyIterator :
public iterator<bidirectional_iterator_tag, double, long, T*, T&> {
// code implementing ++, etc.
}; — end example
namespace std {
enum codecvt_mode {
consume_header = 4,
generate_header = 2,
little_endian = 1
};
template <class Elem, unsigned long Maxcode = 0x10ffff, codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf8 : public codecvt<Elem, char, mbstate_t> {
public:
explicit codecvt_utf8(size_t refs = 0);
~codecvt_utf8();
};
template <class Elem, unsigned long Maxcode = 0x10ffff, codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf16 : public codecvt<Elem, char, mbstate_t> {
public:
explicit codecvt_utf16(size_t refs = 0);
~codecvt_utf16();
};
template <class Elem, unsigned long Maxcode = 0x10ffff, codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf8_utf16 : public codecvt<Elem, char, mbstate_t> {
public:
explicit codecvt_utf8_utf16(size_t refs = 0);
~codecvt_utf8_utf16();
};
}
namespace std {
template <class Codecvt, class Elem = wchar_t,
class Wide_alloc = allocator<Elem>,
class Byte_alloc = allocator<char>>
class wstring_convert;
template <class Codecvt, class Elem = wchar_t,
class Tr = char_traits<Elem>>
class wbuffer_convert;
}wstring_convert<std::codecvt_utf8<wchar_t>> myconv; std::string mbstring = myconv.to_bytes(L"Hello\n"); std::cout << mbstring;
namespace std {
template <class Codecvt, class Elem = wchar_t,
class Wide_alloc = allocator<Elem>,
class Byte_alloc = allocator<char>>
class wstring_convert {
public:
using byte_string = basic_string<char, char_traits<char>, Byte_alloc>;
using wide_string = basic_string<Elem, char_traits<Elem>, Wide_alloc>;
using state_type = typename Codecvt::state_type;
using int_type = typename wide_string::traits_type::int_type;
explicit wstring_convert(Codecvt* pcvt = new Codecvt);
wstring_convert(Codecvt* pcvt, state_type state);
explicit wstring_convert(const byte_string& byte_err,
const wide_string& wide_err = wide_string());
~wstring_convert();
wstring_convert(const wstring_convert&) = delete;
wstring_convert& operator=(const wstring_convert&) = delete;
wide_string from_bytes(char byte);
wide_string from_bytes(const char* ptr);
wide_string from_bytes(const byte_string& str);
wide_string from_bytes(const char* first, const char* last);
byte_string to_bytes(Elem wchar);
byte_string to_bytes(const Elem* wptr);
byte_string to_bytes(const wide_string& wstr);
byte_string to_bytes(const Elem* first, const Elem* last);
size_t converted() const noexcept;
state_type state() const;
private:
byte_string byte_err_string; // exposition only
wide_string wide_err_string; // exposition only
Codecvt* cvtptr; // exposition only
state_type cvtstate; // exposition only
size_t cvtcount; // exposition only
};
}using byte_string = basic_string<char, char_traits<char>, Byte_alloc>;
size_t converted() const noexcept;
wide_string from_bytes(char byte);
wide_string from_bytes(const char* ptr);
wide_string from_bytes(const byte_string& str);
wide_string from_bytes(const char* first, const char* last);
using int_type = typename wide_string::traits_type::int_type;
state_type state() const;
using state_type = typename Codecvt::state_type;
byte_string to_bytes(Elem wchar);
byte_string to_bytes(const Elem* wptr);
byte_string to_bytes(const wide_string& wstr);
byte_string to_bytes(const Elem* first, const Elem* last);
using wide_string = basic_string<Elem, char_traits<Elem>, Wide_alloc>;
explicit wstring_convert(Codecvt* pcvt = new Codecvt);
wstring_convert(Codecvt* pcvt, state_type state);
explicit wstring_convert(const byte_string& byte_err,
const wide_string& wide_err = wide_string());
~wstring_convert();
namespace std {
template <class Codecvt, class Elem = wchar_t, class Tr = char_traits<Elem>>
class wbuffer_convert : public basic_streambuf<Elem, Tr> {
public:
using state_type = typename Codecvt::state_type;
explicit wbuffer_convert(streambuf* bytebuf = 0,
Codecvt* pcvt = new Codecvt,
state_type state = state_type());
~wbuffer_convert();
wbuffer_convert(const wbuffer_convert&) = delete;
wbuffer_convert& operator=(const wbuffer_convert&) = delete;
streambuf* rdbuf() const;
streambuf* rdbuf(streambuf* bytebuf);
state_type state() const;
private:
streambuf* bufptr; // exposition only
Codecvt* cvtptr; // exposition only
state_type cvtstate; // exposition only
};
}state_type state() const;
streambuf* rdbuf() const;
streambuf* rdbuf(streambuf* bytebuf);
using state_type = typename Codecvt::state_type;
explicit wbuffer_convert(
streambuf* bytebuf = 0,
Codecvt* pcvt = new Codecvt,
state_type state = state_type());
~wbuffer_convert();