123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <chapter xml:id="defs.h">
- <title><tt>__vic/defs.h</tt></title>
- <p>Misc. fundamental definitions.</p>
- <chapter xml:id="nullptr">
- <title><tt>nullptr</tt> <sign>C++98 only</sign></title>
- <p>Null pointer literal. Can be used instead of <tt>NULL</tt> or <tt>0</tt>.
- In ISO C++ 98 mode defined as</p>
- <code-block lang="C++">
- const int nullptr = 0;
- </code-block>
- <p>This definition allows to write C++11-style code using C++98 standard.</p>
- <p>It is one of the few global definitions inroduced by the library. Definition
- can be prevented by definition <tt>__VIC_NO_NULLPTR_DEF</tt> macro before
- inclusion.</p>
- <section><title>Example</title>
- <code-block lang="C++"><![CDATA[
- int *p = nullptr;
- pthread_create(&tid, nullptr, thread_func, nullptr);
- ]]></code-block>
- </section>
- </chapter>
- <chapter xml:id="noexcept">
- <title><tt>noexcept</tt> <sign>C++98 only</sign></title>
- <p>A macro in C++98 mode, synonym for <tt>throw()</tt>. In other standard modes
- the definition is absent.</p>
- </chapter>
- <chapter xml:id="array_size">
- <title><tt>array_size()</tt></title>
- <code-block lang="C++"><![CDATA[
- template<class T, size_t N>
- constexpr size_t array_size(T (&array)[N]);
- ]]></code-block>
- <p>Returns number of elements in the array. Can be used as a compile-time
- expression.</p>
- <section><title>Example</title>
- <code-block lang="C++">
- int m[] = { 1, 2, 3, 5, 7 };
- size_t n = __vic::array_size(m); // n == 5
- int *dup = new int[n];
- </code-block>
- </section>
- </chapter>
- <chapter xml:id="non_copyable">
- <title><tt>non_copyable</tt></title>
- <code-block lang="C++"><![CDATA[
- class non_copyable
- {
- non_copyable(const non_copyable &) = delete;
- non_copyable &operator=(const non_copyable &) = delete;
- protected:
- non_copyable() = default;
- };
- ]]></code-block>
- <p>Inheriting of this class suppresses generation of copy constructor and
- copy assignment. Same as <tt>boost::noncopyable</tt>.</p>
- <section><title>Example</title>
- <code-block lang="C++">
- class C : private __vic::non_copyable
- {
- };
- C c1;
- C c2 = c1; // Error! Non-copyable object
- </code-block>
- </section>
- </chapter>
- <chapter xml:id="non_heap_allocatable">
- <title><tt>non_heap_allocatable</tt></title>
- <code-block lang="C++"><![CDATA[
- class non_heap_allocatable
- {
- void *operator new(std::size_t ) = delete;
- void *operator new(std::size_t , const std::nothrow_t & ) = delete;
- void *operator new[](std::size_t ) = delete;
- void *operator new[](std::size_t , const std::nothrow_t & ) = delete;
- protected:
- non_heap_allocatable() = default;
- };
- ]]></code-block>
- <p>Inheriting of this class prevents creation of the class object on a free
- store using operator <tt>new</tt>.</p>
- <section><title>Example</title>
- <code-block lang="C++">
- class C : private __vic::non_heap_allocatable
- {
- };
- C c; // Ok. Allocation on stack
- C *p = new C; // Error! Attempt to allocate on heap
- </code-block>
- </section>
- </chapter>
- <chapter xml:id="std--move">
- <title><tt>std::move()</tt>, <tt>std::forward()</tt>, <tt>std::swap()</tt>
- <sign>C++11</sign></title>
- <p>The header always includes this utilities in C++11 mode.</p>
- </chapter>
- <chapter xml:id="VIC_SWAP_HEADER">
- <title><tt>__VIC_SWAP_HEADER</tt></title>
- <p>A macro for <tt>#include</tt>. Expands to the header name that contains
- <tt>std::swap()</tt> definition, dependig on the used language standard.</p>
- <section><title>Example</title>
- <code-block lang="C++">
- #include __VIC_SWAP_HEADER
- </code-block>
- </section>
- </chapter>
- <chapter xml:id="platform-dependent-macros">
- <title>Platform-dependent macros</title>
- <p>The library provides set of compiler-independent macros that help to
- determine the target platform and some platform-specific traits by checking
- macro presence using <tt>#ifdef</tt>.</p>
- <p>List of hardware platforms (processors):</p>
- <list style="bulleted">
- <item><tt>__VIC_X86__</tt> - Intel x86 (IA32)</item>
- <item><tt>__VIC_X64__</tt> - x64 aka AMD 64</item>
- <item><tt>__VIC_IA64__</tt> - Intel IA64</item>
- <item><tt>__VIC_POWERPC__</tt> - PowerPC</item>
- </list>
- <p>Other macros:</p>
- <list style="bulleted">
- <item><tt>__VIC_STRICT_RAM_ALIGNMENT__</tt> - attempt to read unaligned
- data will cause bus error</item>
- </list>
- </chapter>
- </chapter>
|