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 * void foo2() {} 157 * \endcode 158 * 159 * \code 160 * void bar() {} 161 * 162 * void bar2() {} 163 * \endcode 164 * 165 * Alternative way of writing code, has a complicated workaround 166 * because doxygen treats the empty line as a paragraph 167 * separator: 168 * 169 * <pre> 170 * int bar(); 171 * 172 * int bar2(); 173 * </pre> 174 * 175 * Unfortunately the workaround will merge consecutive blocks, 176 * like this: 177 * 178 * <pre> 179 * int foo(); 180 * </pre> 181 * 182 * <pre> 183 * int foo2(); 184 * </pre> 185 * 186 * \tparam TypeParameter A template parameter 187 * \tparam NonTypeParameter This is a non-type template parameter 188 * \tparam TypeParameterWithDefault This is a template parameter with a default argument 189 */ 190 191 template <typename TypeParameter, int NonTypeParameter, 192 typename TypeParameterWithDefault = int> 193 struct example_template {}; 194 195 /** 196 * \param i A function parameter 197 * \param j Another 198 * \return The answer 199 * \pre i > j 200 * 201 * This is a test function. 202 * \ref example::example "Link to class" 203 * \ref example_template "Link to class template" 204 * \note This is a note. 205 * 206 * \see example::example and example_template 207 */ 208 int namespace_func(int i, int j); 209 210 /** 211 * Testing a function template. 212 * \tparam TypeParameter A template parameter 213 * \tparam NonTypeParameter This is a non-type template parameter 214 */ 215 template <typename TypeParameter, int NonTypeParameter> 216 void namespace_func_template(); 217 218 template<class T> 219 struct specialization_test { 220 }; 221 222 template<class T> 223 struct specialization_test<T*> { 224 /** A constructor. */ 225 specialization_test(); 226 /** A destructor. */ 227 ~specialization_test(); 228 /** An assignment operator. */ 229 detail::unspecified& operator=(const specialization_test&); 230 }; 231 } 232 233 #define EXAMPLE(m) The macro 234