You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As we will declare many classes (Fsa, AuxLabels, Cfsa, etc.) with Array2, wondering if there is any convenient way to create alias of indexes and data so that we can use those alias in functions to make code clear (otherwise we may create those alias in functions again and again)
For example (pseudo code)
using Fsa = Array2<Arc*, int32_t>
alias Fsa::arc_indexes = Fsa::indexes;
alias Fsa::arcs = Fsa::data;
One possible approach I thought of is wrapping Array2 in a struct:
(Two extra advantages of using struct here are that:
Users cannot misuse class as another class that has the same template parameters in Array2, for example they can not pass Fsa to a function that accepts Cfsa where Fsa = Cfsa = Array2<Arc*, int32_t>)
We can define extra methods in those structs, such as NumStates(), FinalStates(), NumArcs. Otherwise it seems we could just define those methods in Python code (and cannot do this in C++ code)?
)
The text was updated successfully, but these errors were encountered:
On Tue, Jun 9, 2020 at 4:43 PM Haowen Qiu ***@***.***> wrote:
As we will declare many classes (Fsa, AuxLabels, Cfsa, etc.) with Array2,
wondering if there is any convenient way to create alias of indexes and
data so that we can use those alias in functions to make code clear
(otherwise we may create those alias in functions again and again)
For example (pseudo code)
using Fsa = Array2<Arc*, int32_t>
alias Fsa::arc_indexes = Fsa::indexes;
alias Fsa::arcs = Fsa::data;
One possible approach I thought of is wrapping Array2 in a struct:
struct Fsa {
Array2<Arc *, int32_t> m;
Arc *&arcs = m.data;
int32_t *&arc_indexes = m.indexes;
};
(An extra advantage of using struct here is that users cannot misuse class
as another class that has the same template parameters in Array2, for
example they can not pass Fsa to a function that accepts Cfsa, where using
Fsa = Array2<Arc*, int32_t>, using Cfsa = Array2<Arc*, int32_t>)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/danpovey/k2/issues/56>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZFLO5VV7QYRHL76W56HETRVXY3NANCNFSM4NZF3MIA>
.
As we will declare many classes (Fsa, AuxLabels, Cfsa, etc.) with
Array2
, wondering if there is any convenient way to create alias ofindexes
anddata
so that we can use those alias in functions to make code clear (otherwise we may create those alias in functions again and again)For example (pseudo code)
One possible approach I thought of is wrapping
Array2
in a struct:(Two extra advantages of using struct here are that:
Array2
, for example they can not pass Fsa to a function that accepts Cfsa whereFsa = Cfsa = Array2<Arc*, int32_t>
)NumStates()
,FinalStates()
,NumArcs
. Otherwise it seems we could just define those methods in Python code (and cannot do this in C++ code)?)
The text was updated successfully, but these errors were encountered: