Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
parameter pack workaround
#include <cstdlib> #include <iostream> #include <sstream> #include <vector> template <std::size_t> struct const_size_t { using type = std::size_t; }; template<typename ClassType, std::size_t... Dims> class MatrixCell { private: std::vector<std::size_t> coordinateIndices_; ClassType data_; public: MatrixCell() : coordinateIndices_{Dims...} {} void addItem( ClassType item, typename const_size_t<Dims>::type... dims) { if ( !checkIndex( dims... ) ) { std::ostringstream strStream; strStream << __FUNCTION__ << " current index doesn't exist."; // Logger::log( strStream, Logger::TYPE_ERROR ); // throw ExceptionHandler( strStream ); } else { data_ = item; } } private: bool checkIndex(typename const_size_t<Dims>::type... dims) { return true; } }; int main() { std::cout << "Runs OK\n"; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
list multiply
hgh
Rounding in C++
32
Regex pipe and tabs c++
MSVC-IsBaseOf
#27
parantheses matching using stack in C++ - test
Postfix side effect returning 2
Time Zone Registry
Please log in to post a comment.