さて、私はテストプログラムをうまく構築しました:
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
しかし、私がboost::mpl::map用のものを試したとき、それはbarfed:
#include <boost/mpl/map.hpp>
#include <boost/mpl/assert.hpp>
int main()
{
using std::is_same;
using boost::mpl::at;
using boost::mpl::long_;
using boost::mpl::void_;
using boost::mpl::map;
using boost::mpl::pair;
//using namespace boost::mpl;
typedef map <
pair<int, unsigned>
, pair<char, unsigned char>
, pair<long_<5>, char[17]>
, pair < int[42], bool >
> m;
BOOST_MPL_ASSERT_RELATION(size<m>::value, == , 4);
BOOST_MPL_ASSERT_NOT((empty<m>));
BOOST_MPL_ASSERT((is_same< at<m, int>::type, unsigned >));
BOOST_MPL_ASSERT((is_same< at<m, long_<5> >::type, char[17] >));
BOOST_MPL_ASSERT((is_same< at<m, int[42]>::type, bool >));
BOOST_MPL_ASSERT((is_same< at<m, long>::type, void_ >));
return 0;
}
これはコンパイラ出力です:
1>------ Build started: Project: example, Configuration: Debug Win32 ------
1> example.cpp
1>c:\projects\example\example\example.cpp(22): error C2027: use of undefined type 'boost::mpl::size<m>'
1>c:\projects\example\example\example.cpp(22): error C2065: 'value' : undeclared identifier
1>c:\projects\example\example\example.cpp(22): error C2975: 'x' : invalid template argument for 'boost::mpl::assert_relation', expected compile-time constant expression
1> c:\boost_1_57_0\boost\mpl\assert.hpp(120) : see declaration of 'x'
1>c:\projects\example\example\example.cpp(22): error C2664: 'int boost::mpl::assertion_failed<0>(boost::mpl::assert<false>::type)' : cannot convert argument 1 from 'boost::mpl::failed ************boost::mpl::assert_relation<0,4,bool boost::mpl::operator ==(boost::mpl::failed,boost::mpl::failed)>::* ***********' to 'boost::mpl::assert<false>::type'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\boost_1_57_0\boost\mpl\assert.hpp(176): error C2027: use of undefined type 'boost::mpl::empty<m>'
1> c:\projects\example\example\example.cpp(23) : see reference to class template instantiation 'boost::mpl::assert_arg_pred<boost::mpl::empty<m>>' being compiled
1>c:\boost_1_57_0\boost\mpl\assert.hpp(176): error C2146: syntax error : missing ';' before identifier 'p_type'
1>c:\boost_1_57_0\boost\mpl\assert.hpp(176): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\boost_1_57_0\boost\mpl\assert.hpp(177): error C2653: 'p_type' : is not a class or namespace name
1>c:\boost_1_57_0\boost\mpl\assert.hpp(177): error C2065: 'value' : undeclared identifier
1>c:\boost_1_57_0\boost\mpl\assert.hpp(177): error C2975: 'unnamed-parameter' : invalid template argument for 'boost::mpl::assert_arg_pred_impl', expected compile-time constant expression
1> c:\boost_1_57_0\boost\mpl\assert.hpp(171) : see declaration of 'unnamed-parameter'
1>c:\boost_1_57_0\boost\mpl\assert.hpp(182): error C2027: use of undefined type 'boost::mpl::empty<m>'
1> c:\projects\example\example\example.cpp(23) : see reference to class template instantiation 'boost::mpl::assert_arg_pred_not<boost::mpl::empty<m>>' being compiled
1>c:\boost_1_57_0\boost\mpl\assert.hpp(182): error C2146: syntax error : missing ';' before identifier 'p_type'
1>c:\boost_1_57_0\boost\mpl\assert.hpp(182): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\boost_1_57_0\boost\mpl\assert.hpp(183): error C2653: 'p_type' : is not a class or namespace name
1>c:\boost_1_57_0\boost\mpl\assert.hpp(183): error C2065: 'value' : undeclared identifier
1>c:\boost_1_57_0\boost\mpl\assert.hpp(183): error C2057: expected constant expression
1>c:\boost_1_57_0\boost\mpl\assert.hpp(184): error C2975: 'unnamed-parameter' : invalid template argument for 'boost::mpl::assert_arg_pred_impl', expected compile-time constant expression
1> c:\boost_1_57_0\boost\mpl\assert.hpp(171) : see declaration of 'unnamed-parameter'
1>c:\projects\example\example\example.cpp(23): error C2668: 'boost::mpl::assert_not_arg' : ambiguous call to overloaded function
1> c:\boost_1_57_0\boost\mpl\assert.hpp(203): could be 'boost::mpl::assert<false> boost::mpl::assert_not_arg<boost::mpl::empty<m>>(void (__cdecl *)(Pred),int)'
1> with
1> [
1> Pred=boost::mpl::empty<m>
1> ]
1> c:\boost_1_57_0\boost\mpl\assert.hpp(194): or 'boost::mpl::failed ************boost::mpl::not_<boost::mpl::empty<m>>::* ***********boost::mpl::assert_not_arg<boost::mpl::empty<m>>(void (__cdecl *)(Pred),int)'
1> with
1> [
1> Pred=boost::mpl::empty<m>
1> ]
1> while trying to match the argument list '(void (__cdecl *)(boost::mpl::empty<m>), int)'
1>c:\projects\example\example\example.cpp(25): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
次のことをしても:
#include <boost/mpl/map.hpp>
int main()
{
using std::is_same;
using boost::mpl::at;
using boost::mpl::long_;
using boost::mpl::map;
using boost::mpl::pair;
typedef map <
pair<int, unsigned>
, pair<char, unsigned char>
, pair<long_<5>, char[17]>
, pair < int[42], bool >
> m;
at<m, int>::type a;
return 0;
}
失敗します:
1>------ Build started: Project: example, Configuration: Debug Win32 ------
1> example.cpp
1>c:\projects\example\example\example.cpp(18): error C2027: use of undefined type 'boost::mpl::at<m,int>'
1>c:\projects\example\example\example.cpp(18): error C2065: 'type' : undeclared identifier
1>c:\projects\example\example\example.cpp(18): error C2146: syntax error : missing ';' before identifier 'a'
1>c:\projects\example\example\example.cpp(18): error C2065: 'a' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
VS Community 2013 Update 4 をインストールしました。使い方が間違っているのでしょうか、それともインストールしたバージョンに問題があるのでしょうか? 1.57.0 のリリース ノートでは何も参照されておらず、バグ システムも参照されていません。