mercredi 21 novembre 2018

Apply function on each value of parameter pack, put return value into array & execute true/false check on it

Have this piece of working code:

 template < class... Objects >
    static void callNotifyOnPointerObjects ( Objects&&... objects ) {
        int arr[] = { 0, ( static_cast< void > ( objects->Notify () ), 0 )... };
        static_cast< void > ( arr );
    }

objects->Notify() return value is bool

How can I do something like this:

template < class... Objects >
    static bool callNotifyOnPointerObjects ( Objects&&... objects ) {
        // Put in this array return values from objects->Notify () execution
        bool rc [sizeof...(objects)] = {false};
        int arr[] = { 0, ( static_cast< void > ( objects->Notify () ), 0 )... };
        static_cast< void > ( arr );
        // check if all values in rc == true and return true or false
        // return result;
    }

Aucun commentaire:

Enregistrer un commentaire