forked from boostorg/fusion
Initial version of std::array for Boost.Fusion
Functional, though ADL issues have not been solved (see README).
This commit is contained in:
22
libs/fusion/test/Jamfile
Normal file
22
libs/fusion/test/Jamfile
Normal file
@ -0,0 +1,22 @@
|
||||
##==============================================================================
|
||||
# Copyright (c) 2013 Mateusz Loskot
|
||||
# Copyright (c) 2003-2006 Joel de Guzman
|
||||
#
|
||||
# Use, modification and distribution is subject to the Boost Software
|
||||
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
#==============================================================================
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
;
|
||||
|
||||
{
|
||||
test-suite fusion_std_array :
|
||||
|
||||
[ run sequence/std_array.cpp : : : : ]
|
||||
|
||||
;
|
||||
}
|
23
libs/fusion/test/sequence/CMakeLists.txt
Normal file
23
libs/fusion/test/sequence/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
project(boost_fusion_std_array)
|
||||
|
||||
if(MSVC)
|
||||
list(APPEND CMAKE_CXX_FLAGS /Za)
|
||||
else()
|
||||
list(APPEND CMAKE_CXX_FLAGS -pedantic -Wall)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
list(APPEND CMAKE_CXX_FLAGS -std=c++0x)
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER}" MATCHES "clang")
|
||||
list(APPEND CMAKE_CXX_FLAGS -std=c++11)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
find_package(Boost 1.54)
|
||||
if (NOT Boost_FOUND)
|
||||
message(FATAL_ERROR "Cannot find Boost")
|
||||
endif()
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
|
||||
add_executable(std_array std_array.cpp)
|
42
libs/fusion/test/sequence/std_array.cpp
Normal file
42
libs/fusion/test/sequence/std_array.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
//
|
||||
// Copyright (C) 2013 Mateusz Loskot <mateusz@loskot.net>
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy
|
||||
// at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#pragma warning(disable:4180)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/fusion/adapted/std_array.hpp>
|
||||
#include <array>
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic.hpp>
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/support/is_view.hpp>
|
||||
#include <boost/fusion/iterator.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::fusion;
|
||||
typedef std::array<int,3> array_type;
|
||||
|
||||
|
||||
BOOST_MPL_ASSERT((traits::is_sequence<array_type>));
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_view<array_type>));
|
||||
|
||||
array_type arr = {{1,2,3}};
|
||||
|
||||
BOOST_TEST(*boost::fusion::begin(arr) == 1);
|
||||
BOOST_TEST(*boost::fusion::next(boost::fusion::begin(arr)) == 2);
|
||||
BOOST_TEST(*advance_c<2>(boost::fusion::begin(arr)) == 3);
|
||||
BOOST_TEST(prior(boost::fusion::next(boost::fusion::begin(arr))) == boost::fusion::begin(arr));
|
||||
BOOST_TEST(*prior(boost::fusion::end(arr)) == 3);
|
||||
BOOST_TEST(at_c<2>(arr) == 3);
|
||||
BOOST_TEST(size(arr) == 3);
|
||||
BOOST_TEST(distance(boost::fusion::begin(arr), boost::fusion::end(arr)) == 3);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user