Skip to content

[0023] auto keyword, at least C++11 style #24

@devshgraphicsprogramming

Description

Is your feature request related to a problem? Please describe.

The lack of auto makes it impossible to define the following very useful function

template<typename DfDu_t, typename DuDx_t>
auto applyChainRule(const DfDu_t DfDu, const DuDx_t DuDx)
{
    return DfDu*DuDx;
}

as it stands right now I have to provide a manual overload or specialization for every floatNxP floatPxM combo.

Also because there are no constructors, the code gets really long and redundant.

template<class A, class B, class C>
struct MyReallyVeryLongNamedStruct
{
    static MyReallyVeryLongNamedStruct<A,B,C> create(); 
};

void main()
{
    MyReallyVeryLongNamedStruct<SomethingA,AnotherB,OtherC> annoyingVariableToShowcase = MyReallyVeryLongNamedStruct<SomethingA,AnotherB,OtherC>::create();
}

Describe the solution you'd like

Being able to use auto for when:

  • return type
  • variable type due to assignment
    can already be deduced trivially.

Describe alternatives you've considered

I could make an ugly template struct with and internal using alias which tells me the resulting type of every matrix multiplication.

template<typename DfDu_t, typename DuDx_t>
impl::matrix_mul<DfDu_t,DuDx_t>::result_t applyChainRule(const DfDu_t DfDu, const DuDx_t DuDx)
{
    return DfDu*DuDx;
}

But that shifts the problem of having to do the manual specialization onto a struct.

Also that doesn't scale well to other things.

Metadata

Metadata

Assignees

Labels

Theme:C++Issues related to differences or features of C++active proposalIssues relating to active proposals

Type

No type
No fields configured for issues without a type.

Projects

Status
Triaged
Status
No status

Relationships

None yet

Development

No branches or pull requests

Issue actions