Face Engine SDK
5.25.0
A face detection, recognition and tracking engine.
|
00001 #pragma once 00002 00003 #include <fsdk/Types/Result.h> 00004 00005 #include <cassert> 00006 #include <type_traits> 00007 #include <utility> 00008 00009 namespace fsdk { 00020 template <typename R, typename V, class Enable = void> 00021 struct ResultValue : Result<R> {}; 00022 00023 template <typename R, typename V> 00024 struct ResultValue<R, V, typename std::enable_if<std::is_copy_constructible<V>::value>::type> : Result<R> { 00026 typedef R EnumType; 00027 00029 typedef V ValueType; 00030 00034 ResultValue(R result) noexcept 00035 : Result<R>(result) 00036 , m_value{} { 00037 } 00038 00043 ResultValue(R result, const V& value) noexcept 00044 : Result<R>(result) 00045 , m_value(value) { 00046 } 00047 00052 ResultValue(R result, V&& value) noexcept 00053 : Result<R>(result) 00054 , m_value(std::move(value)) { 00055 } 00056 00061 const V& getValue() const noexcept { 00062 assert(this->isOk() && "Acessing value of erroneous result."); 00063 return m_value; 00064 } 00065 00072 V&& takeValue() noexcept { 00073 return std::move(m_value); 00074 } 00075 00080 const V* operator->() const noexcept { 00081 return &getValue(); 00082 } 00083 00084 protected: 00085 V m_value; 00086 }; 00087 00097 template <typename R, typename V> 00098 struct ResultValue<R, V, typename std::enable_if<std::is_copy_constructible<V>::value == false>::type> : 00099 Result<R> { 00101 typedef R EnumType; 00102 00104 typedef V ValueType; 00105 00109 ResultValue(R result) noexcept 00110 : Result<R>(result) 00111 , m_value{} { 00112 } 00113 00118 ResultValue(R result, V&& value) noexcept 00119 : Result<R>(result) 00120 , m_value(std::move(value)) { 00121 } 00122 00127 const V& getValue() const noexcept { 00128 assert(this->isOk() && "Acessing value of erroneous result."); 00129 return m_value; 00130 } 00131 00138 V&& takeValue() noexcept { 00139 return std::move(m_value); 00140 } 00141 00146 const V* operator->() const noexcept { 00147 return &getValue(); 00148 } 00149 00150 protected: 00151 V m_value; 00152 }; 00153 00164 template <typename R, typename V> 00165 inline ResultValue<R, typename std::remove_const<typename std::remove_reference<V>::type>::type> 00166 makeResultValue(R result, V&& value) noexcept { 00167 return ResultValue<R, typename std::remove_const<typename std::remove_reference<V>::type>::type>( 00168 result, 00169 std::forward<V>(value)); 00170 } 00171 } // namespace fsdk