فهرست منبع

common/math_util: Provide a template deduction guide for Common::Rectangle

Allows for things such as:

auto rect = Common::Rectangle{0, 0, 0, 0};

as opposed to being required to explicitly write out the underlying
type, such as:

auto rect = Common::Rectangle<int>{0, 0, 0, 0};

The only requirement for the deduction is that all constructor arguments
be the same type.
Lioncash 7 سال پیش
والد
کامیت
1edf018319
1فایلهای تغییر یافته به همراه3 افزوده شده و 0 حذف شده
  1. 3 0
      src/common/math_util.h

+ 3 - 0
src/common/math_util.h

@@ -41,4 +41,7 @@ struct Rectangle {
     }
 };
 
+template <typename T>
+Rectangle(T, T, T, T)->Rectangle<T>;
+
 } // namespace Common