Question: I'm declaring my std::map and use it below:

```
    map<int, int, function<bool (int, int)>> m;
    m.insert(make_pair(12,3));
    m.insert(make_pair(3,4));
    for(auto & p : m){
        cout << p.first << "," << p.second << endl;
    }

```

g++ compiles, no error.
Template parameter only requires a type, but no function body is required, passes compilation. I was wondering how this empty comparer would behave. On running it:

```
terminate called after throwing an instance of 'std::bad_function_call'
  what():  bad_function_call

```

I only see this error in calling pure virtual function. But my code is using stl template, no polymorphism is in place.

So is this a c++ design issue, that compilation doesn't check if a function only has declaration but no function body to run? Plus, how would c++ standard deal with this?

Appreciate your explanations.

Answer: 
Just in `didSelectItemAt` write a switch case.

```
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

    if collectionView == firstCV {
        handleCases(text : firstData[indexPath.item])
    } else {
        handleCases(text : secondData[indexPath.item])
    }

}

func handleCases(text : String) {
    switch text {
        case firstData[0]:
            print("clicked \(firstData[0])
            // write here code to go to details
            break

        case firstData[1]:
            print("clicked \(firstData[0])
            break

        // put all 6 cases of firstData and secondData and then default
    }
}

```

---

Another solution will be add IBAction inside cell and call `handleCases(text : String)` inside cell in this IBAction.
It looks like you only defined `@IBOutlet` variables for your buttons. Create `@IBAction` functions and put the code that "open new windows" (i.e. performs segues) in that function.

There are many resources online explaining how to do that. One of them is [this one](https://www.hackingwithswift.com/read/2/5/from-outlets-to-actions-creating-an-ibaction).