Ensure that we pick the shorter subspan
Change-Id: I7763ffc27b9fe71b1fd580039e3bd5770918c49d
diff --git a/cpp/BUILD b/cpp/BUILD
index 93a052b..bd1b545 100644
--- a/cpp/BUILD
+++ b/cpp/BUILD
@@ -12,3 +12,9 @@
name = "tapp",
srcs = ["tapp.cc"],
)
+
+
+cc_binary(
+ name = "pick_shorter",
+ srcs = ["pick_shorter.cc"],
+)
diff --git a/cpp/pick_shorter.cc b/cpp/pick_shorter.cc
new file mode 100644
index 0000000..1e514e5
--- /dev/null
+++ b/cpp/pick_shorter.cc
@@ -0,0 +1,31 @@
+// Copyright 2019 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <iostream>
+#include <memory>
+
+struct Point {
+ int x;
+ int y;
+ Point(int x, int y) : x(x), y(y) {}
+};
+
+int main(int argc, char** argv) {
+
+ // Problem was that we were picking not "Point" to highlight, but the
+ // unique_ptr<Point
+ std::unique_ptr<Point> myPoint(new Point(7, 24));
+ std::cout << myPoint->x << "," << myPoint->y << std::endl;
+ return 0;
+}