File: example.hpp

package info (click to toggle)
boost1.88 1.88.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 576,932 kB
  • sloc: cpp: 4,149,234; xml: 136,789; ansic: 35,092; python: 33,910; asm: 5,698; sh: 4,604; ada: 1,681; makefile: 1,633; pascal: 1,139; perl: 1,124; sql: 640; yacc: 478; ruby: 271; java: 77; lisp: 24; csh: 6
file content (236 lines) | stat: -rw-r--r-- 6,802 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236

// Copyright 2009 Daniel James.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

/*!
    \class example::example
    
    \brief Documentation for class example

    Detailed documentation

    \code{.cpp}
    void class_code_sample();
    \endcode
 */

/*!
    \def EXAMPLE
    
    \brief Documentation for macro example
 */

int global_integer;
static int global_static_integer;
const int global_const_integer = 1;
static const int global_static_const_integer = 2;
enum global_enum { enumerator1 = 1, enumerator2 };

namespace example
{
    /*!

    \param x Parameter description.

    \code{.cpp}
    void function_code_sample();
    \endcode
     */
    void free_function(int x);

    int namespace_integer;
    static int namespace_static_integer;
    const int namespace_const_integer = 1;
    static const int namespace_static_const_integer = 2;
    enum namespace_enum { enumerator };

    class example
    {
    public:
        example(example const&) = default;
        example& operator=(example const&) = delete;
        virtual int virtual_method();
        virtual int virtual_abstract_method() = 0;
        virtual int virtual_const_method() const;
        int method_with_default_value(int = default_value);

        int method_with_fp(int (*fp)(), volatile char);
        int method_with_string_default1(char* = ")", volatile char);
        int method_with_string_default2(char* = "(", volatile char);
        int method_with_char_default1(char = '(', volatile char);
        int method_with_char_default2(char = ')', volatile char);

        int volatile_method_with_fp(int (*fp)(), volatile char) volatile;
        int volatile_method_with_string_default1(char* = ")", volatile char) volatile;
        int volatile_method_with_string_default2(char* = "(", volatile char) volatile;
        int volatile_method_with_char_default1(char = '(', volatile char) volatile;
        int volatile_method_with_char_default2(char = ')', volatile char) volatile;

        void const_method() const;
        void volatile_method() volatile;

        void trad_noexcept() noexcept;
        void trad_noexcept_if() noexcept(a == b && (c || d));
        void boost_noexcept() BOOST_NOEXCEPT;
        void boost_noexcept_if() BOOST_NOEXCEPT_IF(a == b && (c || d));

        void trad_constexpr() constexpr;
        void boost_constexpr() BOOST_CONSTEXPR;
        void boost_constexpr_or_const() BOOST_CONSTEXPR_OR_CONST;

        void constexpr_noexcept() constexpr noexcept;

        static int static_method();
        static int static_constexpr() constexpr;

        int integer;
        static int static_integer;
        mutable int mutable_integer;
        const int const_integer;
        static const int static_const_integer;

        // Visual check of typedef alignment.
        /** This type has documentation. */
        typedef int documented_type1;
        /** \brief This type has documentation. */
        typedef long documented_type2;
        /** This type has documentation. */
        typedef long double documented_type3;
        typedef short undocumented_type1;
        typedef double undocumented_type2;
        
        class inner_class {
        public:
            int x;
        };

        enum class_enum { enumerator };
        
        /// INTERNAL ONLY
        enum internal_enum { internal_enumerator };

        explicit operator int();
    protected:
        int protected_integer;
        static int protected_static_integer;
        mutable int protected_mutable_integer;
        const int protected_const_integer;
        static const int protected_static_const_integer;

        enum protected_class_enum { enumerator2 };
    private:
        int private_integer;
        static int private_static_integer;
        mutable int private_mutable_integer;
        const int private_const_integer;
        static const int private_static_const_integer;

        enum private_class_enum { enumerator3 };
    };
    
    /**
     * Test some doxygen markup
     *
     * \warning This is just an example.
     *
     * Embedded docbook list:
     *
     * \xmlonly
     * <orderedlist><listitem><simpara>1</simpara></listitem><listitem><simpara>2</simpara></listitem></orderedlist>
     * \endxmlonly
     *
     * \a Special \b Bold \c Typewriter \e Italics \em emphasis \p parameter
     *
     * \arg Arg1 first argument.
     * \arg Arg2 second argument.
     *
     * \li First list item.
     * \li Second list item
     *
     * Line 1\n
     * Line 2
     *
     * \code
     *     void foo() {}
     *     void foo2() {}
     * \endcode
     *
     * \code
     *     void bar() {}
     *
     *     void bar2() {}
     * \endcode
     *
     * Alternative way of writing code, has a complicated workaround
     * because doxygen treats the empty line as a paragraph
     * separator:
     *
     * <pre>
     * int bar();
     *
     * int bar2();
     * </pre>
     *
     * Unfortunately the workaround will merge consecutive blocks,
     * like this:
     *
     * <pre>
     * int foo();
     * </pre>
     *
     * <pre>
     * int foo2();
     * </pre>
     *
     * \tparam TypeParameter A template parameter
     * \tparam NonTypeParameter This is a non-type template parameter
     * \tparam TypeParameterWithDefault This is a template parameter with a default argument
     */

    template <typename TypeParameter, int NonTypeParameter,
        typename TypeParameterWithDefault = int>
    struct example_template {};

    /**
     * \param i A function parameter
     * \param j Another
     * \return The answer
     * \throw std::runtime_error Some error description
     * \throw std::bad_alloc Memory allocation error
     * \throw ~ Free form description of exception throwing
     * \pre i > j
     *
     * This is a test function.
     * \ref example::example "Link to class"
     * \ref example_template "Link to class template"
     * \note This is a note.
     *
     * \see example::example and example_template
     */
    int namespace_func(int i, int j);
    
    /**
     * Testing a function template.
     * \tparam TypeParameter A template parameter
     * \tparam NonTypeParameter This is a non-type template parameter
     */
    template <typename TypeParameter, int NonTypeParameter>
    void namespace_func_template();

    template<class T>
    struct specialization_test {
    };

    template<class T>
    struct specialization_test<T*> {
        /** A constructor. */
        specialization_test();
        /** A destructor. */
        ~specialization_test();
        /** An assignment operator. */
        detail::unspecified& operator=(const specialization_test&);
    };
}

#define EXAMPLE(m) The macro