Imported Upstream version 1.57.0
[platform/upstream/boost.git] / tools / boostbook / test / doxygen / boost / example.hpp
1
2 // Copyright 2009 Daniel James.
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 /*!
7     \class example::example
8     
9     \brief Documentation for class example
10
11     Detailed documentation
12
13     \code{.cpp}
14     void class_code_sample();
15     \endcode
16  */
17
18 /*!
19     \def EXAMPLE
20     
21     \brief Documentation for macro example
22  */
23
24 int global_integer;
25 static int global_static_integer;
26 const int global_const_integer = 1;
27 static const int global_static_const_integer = 2;
28 enum global_enum { enumerator1 = 1, enumerator2 };
29
30 namespace example
31 {
32     /*!
33
34     \param x Parameter description.
35
36     \code{.cpp}
37     void function_code_sample();
38     \endcode
39      */
40     void free_function(int x);
41
42     int namespace_integer;
43     static int namespace_static_integer;
44     const int namespace_const_integer = 1;
45     static const int namespace_static_const_integer = 2;
46     enum namespace_enum { enumerator };
47
48     class example
49     {
50     public:
51         example(example const&) = default;
52         example& operator=(example const&) = delete;
53         virtual int virtual_method();
54         virtual int virtual_abstract_method() = 0;
55         virtual int virtual_const_method() const;
56         int method_with_default_value(int = default_value);
57
58         int method_with_fp(int (*fp)(), volatile char);
59         int method_with_string_default1(char* = ")", volatile char);
60         int method_with_string_default2(char* = "(", volatile char);
61         int method_with_char_default1(char = '(', volatile char);
62         int method_with_char_default2(char = ')', volatile char);
63
64         int volatile_method_with_fp(int (*fp)(), volatile char) volatile;
65         int volatile_method_with_string_default1(char* = ")", volatile char) volatile;
66         int volatile_method_with_string_default2(char* = "(", volatile char) volatile;
67         int volatile_method_with_char_default1(char = '(', volatile char) volatile;
68         int volatile_method_with_char_default2(char = ')', volatile char) volatile;
69
70         void const_method() const;
71         void volatile_method() volatile;
72
73         void trad_noexcept() noexcept;
74         void trad_noexcept_if() noexcept(a == b && (c || d));
75         void boost_noexcept() BOOST_NOEXCEPT;
76         void boost_noexcept_if() BOOST_NOEXCEPT_IF(a == b && (c || d));
77
78         void trad_constexpr() constexpr;
79         void boost_constexpr() BOOST_CONSTEXPR;
80         void boost_constexpr_or_const() BOOST_CONSTEXPR_OR_CONST;
81
82         void constexpr_noexcept() constexpr noexcept;
83
84         static int static_method();
85         static int static_constexpr() constexpr;
86
87         int integer;
88         static int static_integer;
89         mutable int mutable_integer;
90         const int const_integer;
91         static const int static_const_integer;
92
93         // Visual check of typedef alignment.
94         /** This type has documentation. */
95         typedef int documented_type1;
96         /** \brief This type has documentation. */
97         typedef long documented_type2;
98         /** This type has documentation. */
99         typedef long double documented_type3;
100         typedef short undocumented_type1;
101         typedef double undocumented_type2;
102         
103         class inner_class {
104         public:
105             int x;
106         };
107
108         enum class_enum { enumerator };
109         
110         /// INTERNAL ONLY
111         enum internal_enum { internal_enumerator };
112
113         explicit operator int();
114     protected:
115         int protected_integer;
116         static int protected_static_integer;
117         mutable int protected_mutable_integer;
118         const int protected_const_integer;
119         static const int protected_static_const_integer;
120
121         enum protected_class_enum { enumerator2 };
122     private:
123         int private_integer;
124         static int private_static_integer;
125         mutable int private_mutable_integer;
126         const int private_const_integer;
127         static const int private_static_const_integer;
128
129         enum private_class_enum { enumerator3 };
130     };
131     
132     /**
133      * Test some doxygen markup
134      *
135      * \warning This is just an example.
136      *
137      * Embedded docbook list:
138      *
139      * \xmlonly
140      * <orderedlist><listitem><simpara>1</simpara></listitem><listitem><simpara>2</simpara></listitem></orderedlist>
141      * \endxmlonly
142      *
143      * \a Special \b Bold \c Typewriter \e Italics \em emphasis \p parameter
144      *
145      * \arg Arg1 first argument.
146      * \arg Arg2 second argument.
147      *
148      * \li First list item.
149      * \li Second list item
150      *
151      * Line 1\n
152      * Line 2
153      *
154      * \code
155      *     void foo() {}
156      * \endcode
157      *
158      * \tparam TypeParameter A template parameter
159      * \tparam NonTypeParameter This is a non-type template parameter
160      * \tparam TypeParameterWithDefault This is a template parameter with a default argument
161      */
162
163     template <typename TypeParameter, int NonTypeParameter,
164         typename TypeParameterWithDefault = int>
165     struct example_template {};
166
167     /**
168      * \param i A function parameter
169      * \param j Another
170      * \return The answer
171      * \pre i > j
172      *
173      * This is a test function.
174      * \ref example::example "Link to class"
175      * \ref example_template "Link to class template"
176      * \note This is a note.
177      *
178      * \see example::example and example_template
179      */
180     int namespace_func(int i, int j);
181     
182     /**
183      * Testing a function template.
184      * \tparam TypeParameter A template parameter
185      * \tparam NonTypeParameter This is a non-type template parameter
186      */
187     template <typename TypeParameter, int NonTypeParameter>
188     void namespace_func_template();
189
190     template<class T>
191     struct specialization_test {
192     };
193
194     template<class T>
195     struct specialization_test<T*> {
196         /** A constructor. */
197         specialization_test();
198         /** A destructor. */
199         ~specialization_test();
200         /** An assignment operator. */
201         detail::unspecified& operator=(const specialization_test&);
202     };
203 }
204
205 #define EXAMPLE(m) The macro