Ok, I've had a bit of time to try to wrap my head around your code but I still have some questions.
For example, I'm not sure what this is doing:
1 2
|
Orthography()
: m_from(array<wchar_t, N>()), m_to(array<wchar_t, N>()) {}
|
I can tell that this is a constructor but I'm not sure what the colon is for and what is going on after it. I see that m_from and m_to are member variables of type array<wchar_t> but I'm not sure of the syntax involved here with what you are doing with the (array<wchar_t, N>()) after them.
I think I've got a handle on this one:
1 2
|
Orthography(const Orthography& that)
: m_from(that.m_from), m_to(that.m_to) {}
|
That one references an orthography object and near as I can tell, you are getting the m_from and m_to from the "that" orthography object and putting it into the m_from and m_to. Again, I am not sure what is going on with the syntax here with the parenthesis. What are those parenthesis doing in the code like m_from(that.m_from)?
This one:
1 2
|
Orthography(const wstring& f, const wstring& t)
: m_from(toArray<N>(f)), m_to(toArray<N>(t)) {}
|
This looks to be using the template code you had above:
1 2 3 4 5 6 7
|
template<size_t N, class V>
array<wchar_t, N> toArray(const V& v)
{
array<wchar_t, N> d = array<wchar_t, N>();
copy(begin(v), end(v), begin(d));
return d;
}
|
I'm still pretty new to templates so I'm not entire sure what you have going on here.
This last function looks overloads the = operator.
1 2 3 4 5 6
|
Orthography& operator=(const Orthography& that)
{
m_from = that.m_from;
m_to = that.m_to;
return *this;
}
|
The only thing is I am still fuzzy on what "this" is doing exactly. I've read up on it and everything points to (ha!) saying that it is a hidden pointer to the object you are working with. So my questions is what exactly is it doing here? I can see that this function compares member variables but what is it returning when it returns "this"? Since this is an = operator, is it returning something like a true or false value?
The other two functions:
1 2 3 4 5 6 7 8 9
|
const wchar_t* from() const
{
return &m_from[0];
}
const wchar_t* to() const
{
return &m_to[0];
}
|
Those seem to be simple "get" functions.
I'm still working on the rest of the functions. With all of these constructors and such, I'm fuzzy on how I should implement them. Does this work in the same way that I had before but it is just coded differently? This new code of yours doesn't seem to use the CharacterMatch objects. Do they not need to?