I there boolinq - grate opensource LINQ C++ implementation compatable with vs2010. I like its syntax - it looks as close to C# as it gets (from a short look at all other VS2010 LINQ C++ implementations). Yet it really has some base LINQ functions missing. I wonder how can be implemented .First(lambda expression) or .FirstOrDefault(lambda expression) support into it?
Asked
Active
Viewed 856 times
2
1 Answers
1
Since the c++ vectors have the front() and the empty() method, you just have to do the following:
for the
.First(lambda), you just need to check.Where(lambda).ToVector().empty(). If it is true throw an exception, otherwise return.Where(lambda).ToVector().front()for the
.FirstOrDefault(lambda), you just need to check.Where(lambda).ToVector().empty(). If it is true return the default value, otherwise return.Where(lambda).ToVector().front()
888
- 3,246
- 8
- 41
- 60