17 #include <boost/utility.hpp> 20 #include <type_traits> 23 namespace accumulators {
32 template<
typename R,
typename C>
static char helper(R(C::*)()
const);
33 template<
typename C>
static char check(std::integral_constant<std::size_t,
sizeof(helper(&C::owns_weight))>*);
34 template<
typename C>
static double check(...);
35 typedef std::integral_constant<bool, sizeof(char) == sizeof(check<T>(0))>
type;
36 constexpr
static bool value = type::value;
40 struct no_weight_type {};
41 template <
bool,
typename T>
struct weight_type_impl {
42 typedef no_weight_type
type;
44 template <
typename T>
struct weight_type_impl<true, T> {
45 typedef typename T::weight_type
type;
50 typedef typename detail::weight_type_impl<has_feature<T, weight_tag>::type::value, T>
::type type;
59 template<
typename A>
typename std::enable_if<
62 >::type weight_impl(A
const & acc) {
66 template<
typename A>
typename std::enable_if<
67 !has_feature<A, weight_tag>::value
69 >::type weight_impl(A
const &) {
70 throw std::runtime_error(std::string(
typeid(A).name()) +
" has no weight-method" +
ALPS_STACKTRACE);
77 template<
typename T,
typename B>
class BaseWrapper<T, weight_tag, B> :
public B {
79 virtual bool has_weight()
const = 0;
83 template<
typename T,
typename B>
class DerivedWrapper<T, weight_tag, B> :
public B {
base_wrapper< typename value_type< T >::type > const * weight() const
std::integral_constant< bool, sizeof(char)==sizeof(check< T >0))> type
DerivedWrapper(T const &arg)
detail::weight_type_impl< has_feature< T, weight_tag >::type::value, T >::type type
base_wrapper< typename value_type< T >::type > const * weight(T const &arg)