mirror of
https://github.com/boostorg/range.git
synced 2025-07-21 16:42:11 +02:00
*** empty log message ***
[SVN r27671]
This commit is contained in:
@ -15,38 +15,47 @@
|
|||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <mfc/include/afxtempl.h> // for CArray
|
#include <afxtempl.h> // for CArray
|
||||||
#include <boost/range/config.hpp>
|
#include <boost/range/config.hpp>
|
||||||
#include <boost/range/metafunctions.hpp>
|
#include <boost/range/metafunctions.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
template< class T, class U >
|
template< class T, class U >
|
||||||
struct iterator_of< CArray<T,U> >
|
struct range_iterator< CArray<T,U> >
|
||||||
{
|
{
|
||||||
typedef T* type;
|
typedef T* type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Why is this needed?!?
|
||||||
|
//
|
||||||
template< class T, class U >
|
template< class T, class U >
|
||||||
struct const_iterator_of< CArray<T,U> >
|
struct range_iterator< const CArray<T,U> >
|
||||||
|
{
|
||||||
|
typedef T* type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T, class U >
|
||||||
|
struct range_const_iterator< CArray<T,U> >
|
||||||
{
|
{
|
||||||
typedef const T* type;
|
typedef const T* type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T, class U >
|
template< class T, class U >
|
||||||
struct difference_type_of< CArray<T,U> >
|
struct range_difference< CArray<T,U> >
|
||||||
{
|
{
|
||||||
typedef std::ptrdiff_t type;
|
typedef std::ptrdiff_t type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T, class U >
|
template< class T, class U >
|
||||||
struct size_type_of< CArray<T,U> >
|
struct range_size< CArray<T,U> >
|
||||||
{
|
{
|
||||||
typedef int type;
|
typedef int type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T, class U >
|
template< class T, class U >
|
||||||
struct value_type_of< CArray<T,U> >
|
struct range_value< CArray<T,U> >
|
||||||
{
|
{
|
||||||
typedef T type;
|
typedef T type;
|
||||||
};
|
};
|
||||||
|
@ -17,43 +17,57 @@
|
|||||||
|
|
||||||
#include <afx.h> // for CString
|
#include <afx.h> // for CString
|
||||||
#include <boost/range/config.hpp>
|
#include <boost/range/config.hpp>
|
||||||
#include <boost/range/difference_type.hpp>
|
#include <boost/range/metafunctions.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
struct iterator_of< CString >
|
template<>
|
||||||
|
struct range_iterator< CString >
|
||||||
{
|
{
|
||||||
typedef TCHAR* type;
|
typedef TCHAR* type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct const_iterator_of< CString >
|
//
|
||||||
|
// Why is this needed?!?
|
||||||
|
//
|
||||||
|
template<>
|
||||||
|
struct range_iterator< const CString >
|
||||||
|
{
|
||||||
|
typedef TCHAR* type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct range_const_iterator< CString >
|
||||||
{
|
{
|
||||||
typedef const TCHAR* type;
|
typedef const TCHAR* type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct difference_type_of< CString >
|
template<>
|
||||||
|
struct range_difference< CString >
|
||||||
{
|
{
|
||||||
typedef std::ptrdiff_t type;
|
typedef std::ptrdiff_t type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct size_type_of< CString >
|
template<>
|
||||||
|
struct range_size< CString >
|
||||||
{
|
{
|
||||||
typedef int type;
|
typedef int type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct value_type_of< CString >
|
template<>
|
||||||
|
struct range_value< CString >
|
||||||
{
|
{
|
||||||
typedef TCHAR type;
|
typedef TCHAR type;
|
||||||
};
|
};
|
||||||
|
|
||||||
TCHAR* begin( CString& r )
|
TCHAR* begin( CString& r )
|
||||||
{
|
{
|
||||||
return &r[0];
|
return r.GetBuffer(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TCHAR* begin( const CString& r )
|
const TCHAR* begin( const CString& r )
|
||||||
{
|
{
|
||||||
return &r[0];
|
return (LPCTSTR)r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size( const CString& r )
|
int size( const CString& r )
|
||||||
@ -61,12 +75,12 @@ namespace boost
|
|||||||
return r.GetLength();
|
return r.GetLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
T* end( CString& r )
|
TCHAR* end( CString& r )
|
||||||
{
|
{
|
||||||
return begin( r ) + size( r );
|
return begin( r ) + size( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
const T* end( const CString& r )
|
const TCHAR* end( const CString& r )
|
||||||
{
|
{
|
||||||
return begin( r ) + size( r );
|
return begin( r ) + size( r );
|
||||||
}
|
}
|
||||||
|
32
test/mfc.cpp
32
test/mfc.cpp
@ -18,6 +18,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BOOST_RANGE_ENABLE_MFC
|
#define BOOST_RANGE_ENABLE_MFC
|
||||||
|
#define BOOST_RANGE_ENABLE_MCF_CARRAY
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define WIN32
|
||||||
|
#define _WINDOWS
|
||||||
|
#define _MBCS
|
||||||
|
#define _AFXDLL
|
||||||
|
#define _ATL_DLL
|
||||||
|
*/
|
||||||
|
|
||||||
|
///Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_MBCS" /D "_AFXDLL" /D "_ATL_DLL" /Gm /EHsc /RTC1
|
||||||
|
// /MDd /Zc:wchar_t /Yu"stdafx.h" /Fp"Debug/Foo.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /ZI /TP
|
||||||
|
|
||||||
#include <boost/range.hpp>
|
#include <boost/range.hpp>
|
||||||
#include <boost/range/detail/mfc/carray.hpp>
|
#include <boost/range/detail/mfc/carray.hpp>
|
||||||
@ -25,9 +37,6 @@
|
|||||||
|
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <vector>
|
|
||||||
#include <fstream>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
|
|
||||||
void check_mfc()
|
void check_mfc()
|
||||||
@ -36,7 +45,22 @@ void check_mfc()
|
|||||||
BOOST_CHECK( boost::begin( s ) + boost::size( s ) == boost::end( s ) );
|
BOOST_CHECK( boost::begin( s ) + boost::size( s ) == boost::end( s ) );
|
||||||
BOOST_CHECK( boost::size( s ) == boost::size( "hello world" ) );
|
BOOST_CHECK( boost::size( s ) == boost::size( "hello world" ) );
|
||||||
BOOST_CHECK( !boost::empty( s ) );
|
BOOST_CHECK( !boost::empty( s ) );
|
||||||
|
const CString cs( s );
|
||||||
|
BOOST_CHECK( boost::begin( cs ) + boost::size( cs ) == boost::end( cs ) );
|
||||||
|
BOOST_CHECK( boost::size( cs ) == boost::size( "hello world" ) );
|
||||||
|
BOOST_CHECK( !boost::empty( cs ) );
|
||||||
|
|
||||||
|
CArray<int,int> a;
|
||||||
|
BOOST_CHECK( boost::empty( a ) );
|
||||||
|
a.Add( 5 );
|
||||||
|
a.Add( 10 );
|
||||||
|
BOOST_CHECK( boost::begin( a ) + boost::size( a ) == boost::end( a ) );
|
||||||
|
BOOST_CHECK( boost::size( a ) == 2 );
|
||||||
|
BOOST_CHECK( !boost::empty( a ) );
|
||||||
|
const CArray<int,int>& ca = a;
|
||||||
|
BOOST_CHECK( boost::begin( ca ) + boost::size( ca ) == boost::end( ca ) );
|
||||||
|
BOOST_CHECK( boost::size( ca ) == 2 );
|
||||||
|
BOOST_CHECK( !boost::empty( ca ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user