From 18a2500d550bb3503c08e8cf28d1f63864ff0c7f Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Wed, 1 Nov 2017 20:28:07 +0000 Subject: [PATCH] Update doc markdown --- docs/index.md | 56 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/docs/index.md b/docs/index.md index 993f68f..f15be56 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,20 @@ # Header file `optional.hpp` -
namespace tl
+
#define TL_OPTIONAL_HPP
+
+#define TL_OPTIONAL_VERSION_MAJOR
+
+#define TL_OPTIONAL_VERSION_MINOR
+
+#define IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)
+
+#define IS_TRIVIALLY_COPY_ASSIGNABLE(T)
+
+#define IS_TRIVIALLY_DESTRUCTIBLE(T)
+
+#define TL_OPTIONAL_CXX14
+
+namespace tl
 {
     class monostate;
     
@@ -160,8 +174,8 @@ public:
     
     template <class F> auto map(F &&f) &;
     template <class F> auto map(F &&f) &&;
-    template <class F> auto map(F &&f) const &;
-    template <class F> auto map(F &&f) const &&;
+    template <class F> auto map(F &&f) const&;
+    template <class F> auto map(F &&f) const&&;
     
     template <class F> optional<T> or_else (F &&f) &;
     template <class F> optional<T> or_else (F &&f) &&;
@@ -207,9 +221,9 @@ public:
     constexpr optional() noexcept = default;
     constexpr optional(nullopt_t) noexcept;
     
-    constexpr optional(const optional& rhs);
+    constexpr optional(const optional& rhs) = default;
     
-    constexpr optional(optional&& rhs) noexcept(std::is_nothrow_move_constructible<T>::value);
+    constexpr optional(optional&& rhs) = default;
     
     template <class... Args> constexpr explicit optional(in_place_t, Args&&... args);
     template <class U, class... Args>
@@ -225,9 +239,9 @@ public:
     
     optional& operator=(nullopt_t) noexcept;
     
-    optional& operator=(const optional& rhs);
+    optional& operator=(const optional& rhs) = default;
     
-    optional& operator=(optional&& rhs) noexcept(std::is_nothrow_move_assignable<T>::value&&std::is_nothrow_move_constructible<T>::value);
+    optional& operator=(optional&& rhs) = default;
     
     optional &operator=(U &&u);
     
@@ -251,7 +265,7 @@ public:
     constexpr bool has_value() const noexcept;
     constexpr operator bool() const noexcept;
     
-    constexpr T &value();
+    constexpr T& value() &;
     constexpr const T &value() const;
     
     template <class U>
@@ -280,9 +294,7 @@ An optional object is an object that contains the storage for another object and
 
 Carries out some operation which returns an optional on the stored object if there is one.
 
-*Requires*: `std::invoke(std::forward(f), value())` returns a `std::optional` for some `U`.
-
-*Returns*: Let `U` be the result of `std::invoke(std::forward(f), value())`. Returns a `std::optional`. The return value is empty if `*this` is empty, otherwise the return value of `std::invoke(std::forward(f), value())` is returned.
+*Requires*: `std::invoke(std::forward(f), value())` returns a `std::optional` for some `U`. \\returns Let `U` be the result of `std::invoke(std::forward(f), value())`. Returns a `std::optional`. The return value is empty if `*this` is empty, otherwise the return value of `std::invoke(std::forward(f), value())` is returned.
 
 ### Function template `tl::optional::map`
 
@@ -290,9 +302,9 @@ Carries out some operation which returns an optional on the stored object if the
 
 (2)  template <class F> auto map(F &&f) &&;
 
-(3)  template <class F> auto map(F &&f) const &;
+(3)  template <class F> auto map(F &&f) const&;
 
-(4)  template <class F> auto map(F &&f) const &&;
+(4) template <class F> auto map(F &&f) const&&;
Carries out some operation on the stored object if there is one. @@ -308,9 +320,7 @@ Carries out some operation on the stored object if there is one. Calls `f` if the optional is empty -*Requires*: `std::invoke_result_t` must be void or convertible to `optional`. - -*Effects*: If `*this` has a value, returns `*this`. Otherwise, if `f` returns `void`, calls `std::forward(f)` and returns `std::nullopt`. Otherwise, returns `std::forward(f)()`. +*Requires*: `std::invoke_result_t` must be void or convertible to `optional`. \\effects If `*this` has a value, returns `*this`. Otherwise, if `f` returns `void`, calls `std::forward(f)` and returns `std::nullopt`. Otherwise, returns `std::forward(f)()`. ### Function template `tl::optional::map_or` @@ -326,7 +336,7 @@ Calls `f` if the optional is empty (4) template <class F, class U> U map_or(F&& f, U&& u) const &&; -Maps the stored value with `f` if there is one, otherwise returns `u` +Maps the stored value with `f` if there is one, otherwise returns `u`. If there is a value stored, then `f` is called with `**this` and the value is returned. Otherwise `u` is returned. @@ -397,7 +407,7 @@ Constructs an optional that does not contain a value. ### Constructor `tl::optional::optional` -
constexpr optional(const optional& rhs);
+
constexpr optional(const optional& rhs) = default;
Copy constructor @@ -405,7 +415,7 @@ If `rhs` contains a value, the stored value is direct-initialized with it. Other ### Constructor `tl::optional::optional` -
constexpr optional(optional&& rhs) noexcept(std::is_nothrow_move_constructible<T>::value);
+
constexpr optional(optional&& rhs) = default;
Move constructor @@ -454,7 +464,7 @@ Destroys the current value if there is one. ### Assignment operator `tl::optional::operator=` -
optional& operator=(const optional& rhs);
+
optional& operator=(const optional& rhs) = default;
Copy assignment. @@ -462,7 +472,7 @@ Copies the value from `rhs` if there is one. Otherwise resets the stored value i ### Assignment operator `tl::optional::operator=` -
optional& operator=(optional&& rhs) noexcept(std::is_nothrow_move_assignable<T>::value&&std::is_nothrow_move_constructible<T>::value);
+
optional& operator=(optional&& rhs) = default;
Move assignment. @@ -538,12 +548,14 @@ If neither optionals have a value, nothing happens. If both have a value, the va ### Function `tl::optional::value` -
(1)  constexpr T &value();
+
(1)  constexpr T& value() &;
 
 (2)  constexpr const T &value() const;
*Returns*: the contained value if there is one, otherwise throws \[bad\_optional\_access\] +synopsis constexpr T \&value(); + ### Function template `tl::optional::value_or`
(1)  template <class U>