Question Details

No question body available.

Tags

c++ templates parameter-list

Answers (2)

February 15, 2026 Score: 9 Rep: 401,137 Quality: High Completeness: 80%

Three things come to mind:

1. Deduction

When invoking (overloaded) template functions, template argument deduction will deduce the free types. Presumably, you're already aware of this part (because you are using variadics in your example).

c++17 CTAD extends this to constructors of types, e.g. std::vector { 1,2,3 } becomes std::vector, std::array { 1,2,3 } becomes std::array.

2. Template Aliases:

You can either use template aliases:

template 
using MyMap = boost::container::flatmap;

Now you can use the unwieldy type name as

MyMap m;

3. Opaque types / Concepts

In reality, you don't usually care about all the subsidiary details. For example, you might only require a "Range", or a "Container" or a "Map", not some specific instance.

Instead of

template  struct Address {
    std::array details;
};
template  struct Owner {
    std::array details;
};
template  struct HouseRoomsLayout {
    std::tuple data;
};
template  struct House {
    Address         address;
    Owner           owner;
    HouseRoomsLayout layout;
};

You could write

template  struct Address {
    std::array details;
};
template  struct Owner {
    std::array details;
};
template  struct HouseRoomsLayout {
    std::tuple data;
    HouseRoomsLayout(Ts const&... room) : data(room...) {}
};

template Address(T, U...) -> Address; template Owner(T, U...) -> Owner;

template struct House { Address address; Owner owner; Layout layout; };

auto createhousefrom(auto address, auto owner, auto... rooms) { std::cout Address; template Owner(T, U...) -> Owner;

template struct House { Address address; Owner owner; Layout layout; };

int main() { struct Room { std::vector furniture; } backroom; struct Garage { std::vector tools; } garage;

auto h = House{ Address{"Hello Inc"s, "World Drive 42", "Cincinatti", "Uganda"}, Owner{999}, HouseRoomsLayout{backroom, garage}, }; }


Caveat

I'm assuming you're learning about things here. The presented design does not seem like good interface design. At the very least, if you need all that flexibility, make concepts for the different classes of types.

February 15, 2026 Score: 3 Rep: 5,352 Quality: Medium Completeness: 80%

C++ doesn't provide something as you proposed:

using tpl = (typename TA, sizet NA, typename TO, sizet NO, typename ... T);

You can however simplify a bit your design by providing some template parameters AddressT and OwnerT instead:

template 
struct House {};

template auto createhousefrom( AddressT&& address, OwnerT&& owner, Args...args) { return House{}; }

int main() { auto house = createhousefrom ( Address {}, Owner {}, 'a', 42 ); }

Demo

If you still want to have access to all types, you might do the following

template 
struct Address {
    using type = TA;
    static constexpr sizet value = NA;
};
template 
struct Owner {
    using type = TO;
    static constexpr sizet value = NO;
};
template 
struct House {
    using TA = typename AddressT::type;
    static constexpr sizet NA = AddressT::value;
    using TO = typename OwnerT::type;
    static constexpr sizet NO = OwnerT::value;
};

Demo