Code Blocks

| Home | Libraries | People | FAQ | More

## Code Blocks

### Embedded code

These should be syntax highlighted:

    #include <iostream>

    int main()
    {
        // Sample code
        std::cout << "Hello, World\n";
        return 0;
    }

### Code With a Very Long Line

    template <class RealType> RealType inline foo(const RealType& a, const RealType& b, const RealType& c, const RealType& d, const RealType& e, const RealType& f, const RealType& g, const RealType& h){ return 0; }

### Imported code and callouts

Here's some code with left-placed callouts:

    class x
    {
    public:

        x() : n(0)
        {
        }

        ~x()
        {
        }

        int get() const
        {
            return n;
        }

        void set(int n_)
        {
            n = n_;
        }
    };

| Constructor
| Destructor
| Get the `n` member variable
| Set the `n` member variable

And again with callouts placed exactly where we put them:

    std::string foo_bar()
    {
        return "foo-bar";
    }

| The Mythical FooBar. See Foobar for details
| return 'em, foo-bar man!

### Larger example

Now let's include a larger example, this may span several pages and should not be chopped off half way through... some FO processors get this wrong!

    namespace boost{

    template <class BidirectionalIterator>
    class sub_match;

    typedef sub_match<const char*>                    csub_match;
    typedef sub_match<const wchar_t*>                 wcsub_match;
    typedef sub_match<std::string::const_iterator>    ssub_match;
    typedef sub_match<std::wstring::const_iterator>   wssub_match;

    template <class BidirectionalIterator>
    class sub_match : public std::pair<BidirectionalIterator, BidirectionalIterator>
    {
    public:
       typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;
       typedef typename iterator_traits<BidirectionalIterator>::difference_type   difference_type;
       typedef          BidirectionalIterator                                    iterator;

       bool  matched;

       difference_type length()const;
       operator basic_string<value_type>()const;
       basic_string<value_type> str()const;

       int compare(const sub_match& s)const;
       int compare(const basic_string<value_type>& s)const;
       int compare(const value_type* s)const;
    #ifdef BOOST_REGEX_MATCH_EXTRA
       typedef implementation-private capture_sequence_type;
       const capture_sequence_type& captures()const;
    #endif
    };
    //
    // comparisons to another sub_match:
    //
    template <class BidirectionalIterator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                   const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                   const sub_match<BidirectionalIterator>& rhs);

    //
    // comparisons to a basic_string:
    //
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator == (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                              traits,
                                              Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator != (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                              traits,
                                              Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator < (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                              traits,
                                              Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator > (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                              traits,
                                              Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator >= (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                              traits,
                                              Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator <= (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                              traits,
                                              Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                              traits,
                                              Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                              traits,
                                              Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                   const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                           traits,
                                           Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                   const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                           traits,
                                           Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                           traits,
                                           Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type,
                                              traits,
                                              Allocator>& rhs);

    //
    // comparisons to a pointer to a character array:
    //
    template <class BidirectionalIterator>
    bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                   const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                   const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);

    template <class BidirectionalIterator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                   typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                   typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);

    //
    // comparisons to a single character:
    //
    template <class BidirectionalIterator>
    bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                   const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                   const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

    template <class BidirectionalIterator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                   typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                   typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    //
    // addition operators:
    //
    template <class BidirectionalIterator, class traits, class Allocator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
       operator + (const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type,
                                           traits,
                                           Allocator>& s,
                   const sub_match<BidirectionalIterator>& m);
    template <class BidirectionalIterator, class traits, class Allocator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
       operator + (const sub_match<BidirectionalIterator>& m,
                   const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type,
                                           traits,
                                           Allocator>& s);
    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
       operator + (typename iterator_traits<BidirectionalIterator>::value_type const* s,
                   const sub_match<BidirectionalIterator>& m);
    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
       operator + (const sub_match<BidirectionalIterator>& m,
                   typename iterator_traits<BidirectionalIterator>::value_type const * s);
    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
       operator + (typename iterator_traits<BidirectionalIterator>::value_type const& s,
                   const sub_match<BidirectionalIterator>& m);
    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
       operator + (const sub_match<BidirectionalIterator>& m,
                   typename iterator_traits<BidirectionalIterator>::value_type const& s);
    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
       operator + (const sub_match<BidirectionalIterator>& m1,
                   const sub_match<BidirectionalIterator>& m2);

    //
    // stream inserter:
    //
    template <class charT, class traits, class BidirectionalIterator>
    basic_ostream<charT, traits>&
       operator << (basic_ostream<charT, traits>& os,
                   const sub_match<BidirectionalIterator>& m);

    } // namespace boost