|
||||
File indexing completed on 2025-01-18 09:38:14
0001 // Copyright 2019 Hans Dembinski 0002 // 0003 // Distributed under the Boost Software License, Version 1.0. 0004 // (See accompanying file LICENSE_1_0.txt 0005 // or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 0007 #ifndef BOOST_HISTOGRAM_WEIGHT_HPP 0008 #define BOOST_HISTOGRAM_WEIGHT_HPP 0009 0010 #include <utility> 0011 0012 namespace boost { 0013 namespace histogram { 0014 0015 /** Weight holder and type envelope. 0016 0017 You should not construct these directly, use the weight() helper function. 0018 0019 @tparam Underlying arithmetic type. 0020 */ 0021 template <class T> 0022 struct weight_type { 0023 /// Access underlying value. 0024 T value; 0025 0026 /// Allow implicit conversions of types when the underlying value type allows them. 0027 template <class U> 0028 operator weight_type<U>() const { 0029 return weight_type<U>{static_cast<U>(value)}; 0030 } 0031 }; 0032 0033 /** Helper function to mark argument as weight. 0034 0035 @param t argument to be forward to the histogram. 0036 */ 0037 template <class T> 0038 auto weight(T&& t) noexcept { 0039 return weight_type<T>{std::forward<T>(t)}; 0040 } 0041 0042 } // namespace histogram 0043 } // namespace boost 0044 0045 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |