[GCM] Investigatory CHECKs for crash in parsing stream
[chromium-blink-merge.git] / sandbox / linux / bpf_dsl / cons.h
blobeb9e3aa990def77ea9074acfb48b0d0dd587ae0a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SANDBOX_LINUX_BPF_DSL_CONS_H_
6 #define SANDBOX_LINUX_BPF_DSL_CONS_H_
8 #include "base/memory/ref_counted.h"
9 #include "sandbox/sandbox_export.h"
11 namespace sandbox {
13 // Cons provides an immutable linked list abstraction as commonly
14 // provided in functional programming languages like Lisp or Haskell.
15 template <typename T>
16 class Cons : public base::RefCounted<Cons<T> > {
17 public:
18 // List provides an abstraction for referencing a list of zero or
19 // more Cons nodes.
20 typedef scoped_refptr<const Cons<T> > List;
22 // Return this node's head element.
23 const T& head() const { return head_; }
25 // Return this node's tail element.
26 List tail() const { return tail_; }
28 // Construct a new List using |head| and |tail|.
29 static List Make(const T& head, List tail) {
30 return make_scoped_refptr(new const Cons<T>(head, tail));
33 private:
34 Cons(const T& head, List tail) : head_(head), tail_(tail) {}
35 virtual ~Cons() {}
37 T head_;
38 List tail_;
40 friend class base::RefCounted<Cons<T> >;
41 DISALLOW_COPY_AND_ASSIGN(Cons);
44 } // namespace sandbox
46 #endif // SANDBOX_LINUX_BPF_DSL_CONS_H_