Skip to content

Commit 6077d7f

Browse files
authored
Merge pull request #2532 from BioDataAnalysis/enabling-reference-value-type-for-xfunction
Enabling reference value types for xfunction.
2 parents 50b986c + 119d35b commit 6077d7f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

include/xtensor/xfunction.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ namespace xt
142142
struct xcontainer_inner_types<xfunction<F, CT...>>
143143
{
144144
// Added indirection for MSVC 2017 bug with the operator value_type()
145-
using value_type = typename meta_identity<decltype(std::declval<F>()(std::declval<xvalue_type_t<std::decay_t<CT>>>()...))>::type;
146-
using reference = value_type;
147-
using const_reference = value_type;
145+
using func_return_type = typename meta_identity<decltype(std::declval<F>()(std::declval<xvalue_type_t<std::decay_t<CT>>>()...))>::type;
146+
using value_type = std::decay_t<func_return_type>;
147+
using reference = func_return_type;
148+
using const_reference = reference;
148149
using size_type = common_size_type_t<std::decay_t<CT>...>;
149150
};
150151

@@ -439,7 +440,7 @@ namespace xt
439440
using xfunction_type = xfunction<F, CT...>;
440441

441442
using value_type = typename xfunction_type::value_type;
442-
using reference = typename xfunction_type::value_type;
443+
using reference = typename xfunction_type::reference;
443444
using pointer = typename xfunction_type::const_pointer;
444445
using size_type = typename xfunction_type::size_type;
445446
using difference_type = typename xfunction_type::difference_type;

0 commit comments

Comments
 (0)