Convert Initializer List

I need to convert a class written in C ++ 0x to the one compiled in Visual Studio 2008. The code uses std :: initializer_list.

Below is the code

template <typename data_type> class symmatrix { public: typedef data_type value_type; symmatrix(std::initializer_list<T> const& size, value_type ini = value_type()) : m_data(0), m_memory(false) { resize(size); *this = ini; } } 

should be converted to the old standard, understandable by VS 2008.

I am really trying to change 100 lines of new C ++ code to old C ++. So please help me.

+6
source share
1 answer

Instead of initializer_list you can select a pair of iterators. But you also have to change the client code.

If it is a well-written class, it should have other constructors, such as the one I mentioned. In this case, I would recommend just removing the overload that takes initializer_list . You may need to change the client code if it uses this constructor.

+5
source

Source: https://habr.com/ru/post/893480/


All Articles