Home Dashboard Directory Help
Search

Template argument deduction bug (?) by svenschmidt75


Status: 

Active


1
0
Sign in
to vote
Type: Bug
ID: 790270
Opened: 6/16/2013 10:29:27 AM
Access Restriction: Public
1
Workaround(s)
view
0
User(s) can reproduce this bug

Description


There might be a t.a.d. bug in the call to foo:


#include <type_traits>

class Vector {
public:

};

template<typename VECTOR_EXPR1, typename VECTOR_EXPR2, typename BINOP>
class VectorBinaryExpr {
public:
    VectorBinaryExpr(VECTOR_EXPR1 const & lhs, VECTOR_EXPR2 const & rhs) {}
};

template<typename EXPR>
struct expression_traits {
    typedef std::false_type is_vector_expression;
};

template<>
struct expression_traits<Vector> {
    typedef std::true_type is_vector_expression;
};

template<typename T1, typename T2>
typename std::enable_if<
    expression_traits<T1>::is_vector_expression::value,
    VectorBinaryExpr<T1, T2, double>

>::type
foo(T1 lhs, T2 rhs)
{
    return VectorBinaryExpr<T1, T2, double>(lhs, rhs);
}

int main(int argc, char* argv[])
{
    Vector v1;
    Vector v2;

    foo(v1, v2);

    return 0;
}
Details
Sign in to post a comment.
Posted by Microsoft on 7/9/2013 at 11:23 PM
We've also provided a workaround. See the workarounds tab.
Posted by Microsoft on 7/9/2013 at 11:22 PM
Hi s-schmidt,

Thank you for taking the time to provide your feedback. After reviewing your reported issue, in the context of all the issues reported to us, we have decided not to take any action on this feedback at this time. We will re-consider our decision for a future release.

If this issue is severe, causing critical business situations or blocking your product development or deployment, please go to http://support.microsoft.com or call 1-800-MICROSOFT for assistance.
For Microsoft premier customers, please contact your administrator, your Technical Account Manager, or your Microsoft premier account representative.

Thanks,
Karl Niu
Posted by Microsoft on 6/16/2013 at 8:06 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 6/16/2013 at 10:52 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Microsoft on 7/9/2013 at 11:22 PM
template<typename EXPR>
struct expression_traits {
typedef std::false_type is_vector_expression;
enum {value = is_vector_expression::value};
};

template<>
struct expression_traits<Vector> {
typedef std::true_type is_vector_expression;
enum {value = is_vector_expression::value};
};

And use 'expression_traits<type>::value' directly.