Arjun
Arjun

Reputation: 169

Converting Initializer list

I need to convert a class written in C++ 0x to one which compiles in Visual studio 2008. The code uses std::initializer_list.

Following 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; }
}

has to be converted to old standard understood by VS 2008.

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

Upvotes: 6

Views: 891

Answers (1)

Armen Tsirunyan
Armen Tsirunyan

Reputation: 133122

Instead of an initializer_list you can choose to pass a pair of iterators. But you'll have to change client code as well.

If it is a well-written class, it's bound to have other constructors, such as the one I mentioned. In this case I'd recommend to just remove the overload that takes an initializer_list. Client code may have to be changed as well, if it uses that constructor.

Upvotes: 5

Related Questions