Somethimes i need sets (or any other container) of 1 element of user's type and create them this way:
boost::assign::list_of(typeVariable).convert_to_container<std::unordered_set<UserType> >()
Do anyone know more beautiful way?
PS: For example we have any business logic API, which searches for elements, and it takes set (or another container) of types for selection. Different users have access to different types. Also we can select any one type for filtering, and in this case we will take this one type from filtering options.
So i just wanted the simple way to write code in 1 line. My current version is:
getElements(filter.type != UNDEFINED
? boost::assign::list_of(filter.type).convert_to_container<std::set<UserType> >()
: std::set<UserType>(allowedTypes.begin(), allowedTypes.end()))