Created
May 7, 2017 17:37
-
-
Save DanielUranga/d819dc8e26bf2611bd391a1962708e4e to your computer and use it in GitHub Desktop.
null created by danieluranga - https://repl.it/HkrZ/0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Id | |
{ | |
A, B, C, D | |
}; | |
struct Data | |
{ | |
Id id; | |
const char* val; | |
}; | |
const Data arr[] = | |
{ | |
{A, "test"}, | |
{B, "otra cosa"} | |
}; | |
constexpr Data* findById(Id id, Data* arrPtr) | |
{ | |
static_assert(arrPtr <= arr + 1, ""); | |
return id == arrPtr->id ? arrPtr : findById(id, arrPtr + 1); | |
} | |
int main() | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment