Skip to content

kylelutz/make_array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

make_array() - create a fixed size array

--- Introduction ---
The make_array() function constructs a fixed size boost::array<> given 0..N
arguments. It is similar to the std::make_pair() and std::make_tuple()
functions.

--- Interface ---
The make_array() function provides the following interface:

template<class T>
boost::array<T, N> make_array(...)

where the '...' indicates 0 to N arguments.

If no type T is passed explicitly it is deduced to be the type common to all of
the arguments (via boost::common_type<>). The function requires that all of the
arguments be convertible (via static_cast<>) to the explicit type T or the
deduced type.

--- Examples ---
// create 2-component array of type int
boost::array<int, 2> a = boost::make_array(4, 2);

// create 3-component array of type float given int arguments
boost::array<float, 3> = boost::make_array<float>(1, 2, 3);

--- Implementation Details ---
The make_array() function is implemented with C++11 variadic templates if they
are supported by the compiler. Otherwise a fallback implementation uses the 
preprocessor to create N overloads of make_array() where N is defined by
BOOST_MAKE_ARRAY_MAX_ARITY (with a default of 10).

About

make_array() - create a fixed sized array

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages