27 #include "xlnt/utils/exceptions.hpp"    28 #include "xlnt/utils/numeric.hpp"    29 #include <type_traits>    42 #if ((defined(_MSC_VER) && _MSC_VER <= 1900) || (defined(__GNUC__) && __GNUC__ < 5))    44 #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (false)    46 #define XLNT_NOEXCEPT_VALUE_COMPAT(...) (__VA_ARGS__)    47     using ctor_copy_T_noexcept = 
typename std::conditional<std::is_nothrow_copy_constructible<T>{}, std::true_type, std::false_type>::type;
    48     using ctor_move_T_noexcept = 
typename std::conditional<std::is_nothrow_move_constructible<T>{}, std::true_type, std::false_type>::type;
    49     using copy_ctor_noexcept = ctor_copy_T_noexcept;
    50     using move_ctor_noexcept = ctor_move_T_noexcept;
    51     using set_copy_noexcept_t = 
typename std::conditional<std::is_nothrow_copy_constructible<T>{} && std::is_nothrow_assignable<T, T>{}, std::true_type, std::false_type>::type;
    52     using set_move_noexcept_t = 
typename std::conditional<std::is_nothrow_move_constructible<T>{} && std::is_nothrow_move_assignable<T>{}, std::true_type, std::false_type>::type;
    53     using clear_noexcept_t = 
typename std::conditional<std::is_nothrow_destructible<T>{}, std::true_type, std::false_type>::type;
    55     template <typename U = T, typename std::enable_if<!std::is_floating_point<U>::value>::type * = 
nullptr>
    59     constexpr 
bool compare_equal(
const U &lhs, 
const U &rhs)
 const    67     template <typename U = T, typename std::enable_if<std::is_floating_point<U>::value>::type * = 
nullptr>
    68     constexpr 
bool compare_equal(
const U &lhs, 
const U &rhs)
 const    70         return detail::float_equals(lhs, rhs);
    87     optional(
const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{}))
    90         new (&storage_) T(value);
    97     optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{}))
   100         new (&storage_) T(std::move(value));
   108         : has_value_(other.has_value_)
   112             new (&storage_) T(other.value_ref());
   116             std::memset(storage_, 0, 
sizeof(T));
   125         : has_value_(other.has_value_)
   129             new (&storage_) T(std::move(other.value_ref()));
   134             std::memset(storage_, 0, 
sizeof(T));
   144         if (other.has_value_)
   146             set(other.value_ref());
   161         if (other.has_value_)
   163             set(std::move(other.value_ref()));
   193     void set(
const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(set_copy_noexcept_t{}))
   201             new (&storage_) T(value);
   209     void set(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(set_move_noexcept_t{}))
   217             value_ref() = std::move(value);
   221             new (&storage_) T(std::move(value));
   247     void clear() noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(clear_noexcept_t{}))
   251             reinterpret_cast<T *
>(&storage_)->~T();
   291         if (has_value_ != other.has_value_)
   300         return compare_equal(value_ref(), other.value_ref());
   315     T &value_ref() noexcept
   317         return *
reinterpret_cast<T *
>(&storage_);
   320     const T &value_ref() 
const noexcept
   322         return *
reinterpret_cast<const T *
>(&storage_);
   326     alignas(T) 
unsigned char storage_[
sizeof(T)];
   329 #ifdef XLNT_NOEXCEPT_VALUE_COMPAT   330 #undef XLNT_NOEXCEPT_VALUE_COMPAT optional() noexcept
Default contructor. is_set() will be false initially. 
Definition: optional.hpp:77
 
void clear() noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(clear_noexcept_t{}))
After this is called, is_set() will return false until a new value is provided. 
Definition: optional.hpp:247
 
bool is_set() const noexcept
Returns true if this object currently has a value set. This should be called before accessing the val...
Definition: optional.hpp:185
 
optional & operator=(T &&rhs) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(set_move_noexcept_t{}))
Assignment operator overload. Equivalent to setting the value using optional::set. 
Definition: optional.hpp:238
 
optional(optional &&other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(move_ctor_noexcept{}))
Move constructs this optional from other. Clears the value from other if set noexcept if T move ctor ...
Definition: optional.hpp:124
 
bool operator==(const optional< T > &other) const noexcept
Returns true if neither this nor other have a value or both have a value and those values are equal a...
Definition: optional.hpp:289
 
optional(T &&value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_move_T_noexcept{}))
Constructs this optional with a value. noexcept if T move ctor is noexcept 
Definition: optional.hpp:97
 
Enumerates the possible types a cell can be determined by it's current value. 
Definition: cell.hpp:36
 
Exception when setting a class's attribute to an invalid value 
Definition: exceptions.hpp:239
 
Many settings in xlnt are allowed to not have a value set. This class encapsulates a value which may ...
Definition: format.hpp:44
 
optional & operator=(const T &rhs) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(set_copy_noexcept_t{}))
Assignment operator overload. Equivalent to setting the value using optional::set. 
Definition: optional.hpp:229
 
~optional() noexcept
Destructor cleans up the T instance if set 
Definition: optional.hpp:176
 
optional & operator=(const optional &other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(set_copy_noexcept_t{} &&clear_noexcept_t{}))
Copy assignment of this optional from other noexcept if set and clear are noexcept for T& ...
Definition: optional.hpp:142
 
optional(const T &value) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(ctor_copy_T_noexcept{}))
Constructs this optional with a value. noexcept if T copy ctor is noexcept 
Definition: optional.hpp:87
 
optional(const optional &other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(copy_ctor_noexcept{}))
Copy constructs this optional from other noexcept if T copy ctor is noexcept 
Definition: optional.hpp:107
 
optional & operator=(optional &&other) noexcept(XLNT_NOEXCEPT_VALUE_COMPAT(set_move_noexcept_t{} &&clear_noexcept_t{}))
Move assignment of this optional from other noexcept if set and clear are noexcept for T&& ...
Definition: optional.hpp:159
 
bool operator!=(const optional< T > &other) const noexcept
Returns false if neither this nor other have a value or both have a value and those values are equal ...
Definition: optional.hpp:308