HandBooks Professional Java-C-Scrip-SQL part 99

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 99', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | else std cout At least one test failed. Aborting. n With the preceding code there is no way that the code will ever know that one of the tests has failed. As you recall the default combiner is boost last_value and it simply returns the value of the last slot call which is the call to step2. Running the example as-is gives us this disappointing output stepO is ok stepl is not ok. This won t do at all step2 is ok All system tests clear This is clearly not the right result. We need a Combiner that stops processing when a slot returns false and propagates that value back to the signal. A Combiner is nothing more than a function object with a couple of additional requirements. It must have a typedef called result_type which is the return type of its function call operator. Furthermore the function call operator must be parameterized on the iterator type with which it will be invoked. The Combiner that we need right now is quite simple so it serves as a good example. class stop_on_failure public typedef bool result_type template typename InputIterator bool operator InputIterator begin InputIterator end const while begin end if begin return false begin return true Note the public typedef result_type which is bool. The type of result_type doesn t necessarily relate to the return type of the slots. When declaring the signal you specify the signature of the slots and the arguments of the signal s function call operator. However the return type of the Combiner determines the return type of the signal s function call operator. By default this is the same as the return type of the slots but it doesn t have to be the same. stop_on_failure s function call operator which is parameterized on a slot iterator type iterates over the range of slots and calls each one unless we encounter an error. For stop_on_failure we don t want to continue calling the slots on an error return so we test the return value for each call. If it is false the function returns immediately else it continues

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU LIÊN QUAN
5    176    1
5    255    1
5    106    0
5    121    1
6    103    1
6    107    1
6    121    1
6    103    0
6    140    0
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.