forked from OctaForge/libostd
examples/signal: use ConstCharRange
parent
a5c4b9d3ca
commit
ccaedf80dc
|
@ -9,7 +9,7 @@ struct SignalTest {
|
||||||
* can actually emit (in that case, the reference passed to each
|
* can actually emit (in that case, the reference passed to each
|
||||||
* callback will always be const to make sure nothing changes)
|
* callback will always be const to make sure nothing changes)
|
||||||
*/
|
*/
|
||||||
Signal<const SignalTest, int, const char *> on_simple = this;
|
Signal<const SignalTest, int, ConstCharRange> on_simple = this;
|
||||||
Signal< SignalTest, float > on_param = this;
|
Signal< SignalTest, float > on_param = this;
|
||||||
|
|
||||||
SignalTest(): p_param(3.14f) {
|
SignalTest(): p_param(3.14f) {
|
||||||
|
@ -31,7 +31,7 @@ struct SignalTest {
|
||||||
on_simple.emit(150, "hello world");
|
on_simple.emit(150, "hello world");
|
||||||
}
|
}
|
||||||
|
|
||||||
void simple_method(int v, const char *str) const {
|
void simple_method(int v, ConstCharRange str) const {
|
||||||
writefln("simple method handler: %d, %s", v, str);
|
writefln("simple method handler: %d, %s", v, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ int main() {
|
||||||
* this callback can access "test" easily and it will still work
|
* this callback can access "test" easily and it will still work
|
||||||
*/
|
*/
|
||||||
auto idx = st.on_simple.connect([&](const SignalTest &, int v,
|
auto idx = st.on_simple.connect([&](const SignalTest &, int v,
|
||||||
const char *str) {
|
ConstCharRange str) {
|
||||||
writefln("and lambda test: %d, %s (%d)", v, str, test);
|
writefln("and lambda test: %d, %s (%d)", v, str, test);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue