         (forward-word)
         (forward-char -1)
         (setq loc (rtags-peer-member-end-location))))
+    (unless loc
+      ;; Need to handle creation of a buffer with appropriate name
+      (if (member (downcase (file-name-extension (buffer-file-name))) (list "c" "cxx" "cc" "cpp" "c++"))
+          (setq loc (cons (current-buffer) (+ (cdr range) 2)))
+        (let ((fn (buffer-file-name)))
+          (find-file (concat (file-name-sans-extension fn) ".cpp"))
+          (insert "#include \"" (file-name-nondirectory fn) "\"\n")
+          (setq loc (cons (current-buffer) (point))))))
     loc))
 
+(defun rtags-find-member-function ()
+  (save-excursion
+    (let ((start (point))
+          (start (point-at-bol))
+          (valid (list "CXXMethod" "CXXConstructor" "CXXDestructor" "FunctionTemplate"))
+          (sym (rtags-symbol-info-internal nil nil t)))
+      (unless (and sym (member (cdr (assoc 'kind sym)) valid))
+        (goto-char (point-at-eol))
+        (while (and (not sym) (>= (point) start))
+          (setq sym (rtags-symbol-info-internal nil nil t))
+          (unless (and sym (member (cdr (assoc 'kind sym)) valid))
+            (setq sym nil)
+            (backward-word))))
+      sym)))
+
 ;;;###autoload
 (defun rtags-make-member ()
   (interactive)
-  (let* ((member (rtags-symbol-info-internal))
+  (let* ((member (rtags-find-member-function))
          (parent (cdr (assoc 'parent member)))
          (kind (cdr (assoc 'kind member))))
-    (cond ((not kind) (error "No symbol here that I know of"))
-          ((string= kind "CXXMethod"))
-          ((string= kind "CXXConstructor"))
-          ((string= kind "CXXDestructor"))
-          (t (error "Not an appropriate method/constructor/destructor: %s" kind)))
-
+    (unless (and kind (member (cdr (assoc 'kind parent)) (list "ClassDecl" "StructDecl" "ClassTemplate")))
+      (error "No appropriate symbol here that I know of"))
     (when (cdr (assoc 'definition member))
       (error "This is already the definition"))
-    (unless parent
-      (error "Can't find parent"))
     (when (rtags-real-target member)
       (error "%s is already implemented here: %s"
              (cdr (assoc 'symbolName member))

  (when (and (or (buffer-file-name) dired-directory)
             (not (eq (current-buffer) rtags-last-update-current-project-buffer))
             default-directory
             (file-directory-p default-directory))
    (setq rtags-last-update-current-project-buffer (current-buffer))
    (let* ((rc (rtags-executable-find "rc"))

          (let ((location (cdr (assoc 'location target))))
            (when (string-match "\\(.*\\):[0-9]+:[0-9]+:?" location)
              (let ((buffer (find-file-noselect (match-string-no-properties 1 location))))
                ;; (message "GOT target %s for %s (%d:%d)" location (rtags-current-location)
                         ;; (cdr (assoc 'endLine target))
                         ;; (cdr (assoc 'endColumn target)))
                (with-current-buffer buffer
                  (rtags-goto-line-col (cdr (assoc 'endLine target))
                                       (cdr (assoc 'endColumn target)))
                  (cons buffer (1+ (point))))))))))))

(defun rtags-find-location-for-function (range)
  (let (loc)
    (save-excursion
      (while (and (not loc)
