函数成员签名的类模板别名

时间:2019-07-12 22:46:32

标签: c++ templates

如何缩短实施代码?

声明:

this.getAllProducts().pipe(map(p => p.map((s): CartItem => ({
  currency: s.currency,
  product: this.productService.getProduct(s.product).subscribe(p => p),
  quantity: s.quantity,
  selectedColor: s.selectedColor,
  selectedSize: s.selectedSize,
  userId: s.userId
}))));


  private getAllProducts(): Observable<CartResponse[]> {
    return this.http.get<CartResponse[]>('http://localhost:8082/cart/getAllItems?userId=111').pipe(
      map(o => o.map((sp): CartResponse => ({
        quantity: sp.quantity,
        currency: sp.currency,
        product: sp.product,
        selectedColor: sp.selectedColor,
        selectedSize: sp.selectedSize,
        userId: sp.userId
      }))));
  }


export interface CartResponse {
    product: string;
    quantity: number;
    selectedSize: any;
    selectedColor: string;
    currency: string;
    userId: string;
}

export interface CartItem {
    product: Product;
    quantity: number;
    selectedSize: any;
    selectedColor: string;
    currency: string;
    userId: string;
}

实施:

    template<typename Type1,
             typename Type2
    >
    struct SomeStuctWithVeryLongName{
        SomeStuctWithVeryLongName foo();
    };

我要怎么写:

    template<typename Type1,
             typename Type2
    >
    SomeStuctWithVeryLongName<Type1,Type2>   
             SomeStuctWithVeryLongName<Type1,Type2>::foo(){//...}

0 个答案:

没有答案