blob: 6e1d0859ddb28951d42d7a09f0dae795982f6f97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <iostream>
/*
*
* 6.46
*
*
*/
/*
Quick note. Giving constexpr to this function will not work for C++
standards before C++20. If we go by the book this would not work if we
were compiling for C++11 - C++17
This will compile and will work if we are compiling for C++20
*/
constexpr bool isShorter(const std::string &s1, const std::string &s2) {
return s1.size() < s2.size();
}
int main () {
std::cout << (isShorter("1234", "12345") ? "True" : "False") << std::endl;
std::string fourlen = "1234";
std::string fivelen = "12345";
std::cout << (isShorter(fourlen, fivelen) ? "True" : "False") << std::endl;
return 0;
}
|